Apollo-tooling: codegen:generate does not show error details when typing a wrong field

Created on 7 Jul 2018  ยท  1Comment  ยท  Source: apollographql/apollo-tooling

oyb@ouyangbins-iMac:~/Desktop/graphQL/assets$ apollo codegen:generate --schema=tmp/schema.json --target=typescript --addTypename
 โœ” Scanning for GraphQL queries (2 found)
 โœ” Scanning for GraphQL queries (2 found)
 โœ” Loading GraphQL schema
 โœ” Parsing GraphQL schema
 โœ– Generating query files with 'typescript' target
   โ†’ Validation of GraphQL query document failed
ToolError: Validation of GraphQL query document failed
    at Object.validateQueryDocument (/usr/local/lib/node_modules/apollo/lib/validation.js:17:15)
    at Object.generate [as default] (/usr/local/lib/node_modules/apollo/lib/generate.js:19:18)
    at Task.task (/usr/local/lib/node_modules/apollo/lib/commands/codegen/generate.js:100:60)
    at Promise.resolve.then.then.skipped (/usr/local/lib/node_modules/apollo/node_modules/listr/lib/task.js:167:30)
    at <anonymous>

when i modify the file apollo/lib/validation.js add console.error

if (validationErrors && validationErrors.length > 0) {
        for (const error of validationErrors) {
            errors_1.logError(error);
        }
        console.error(new Error(validationErrors)) // add console.error here!!!!
        throw new errors_1.ToolError('Validation of GraphQL query document failed');
    }

```
oyb@ouyangbins-iMac:~/Desktop/graphQL/assets$ apollo codegen:generate --schema=tmp/schema.json --target=typescript --addTypename
โœ” Scanning for GraphQL queries (2 found)
โ ™ Loading GraphQL schema
Parsing GraphQL schema
Generating query files
.../app/routes/authors/authorQuery.graphql: Cannot query field "timestamp2" on type "Author". Did you mean "timestamp"?
Error: Cannot query field "timestamp2" on type "Author". Did you mean "timestamp"?

src/app/routes/authors/authorQuery.graphql (3:20)
2: authors {
3: _id, name, timestamp2
^
4: }

at Object.validateQueryDocument (/Users/oyb/Desktop/graphQL/assets/node_modules/apollo/lib/validation.js:17:23)

โœ” Scanning for GraphQL queries (2 found)
โœ” Loading GraphQL schema
โœ” Parsing GraphQL schema
โœ– Generating query files with 'typescript' target
โ†’ Validation of GraphQL query document failed
[05:59:02] 'hql' errored after 1.62 s
[05:59:02] ToolError: Validation of GraphQL query document failed
at Object.validateQueryDocument (/Users/oyb/Desktop/graphQL/assets/node_modules/apollo/lib/validation.js:18:15)
at Object.generate [as default] (/Users/oyb/Desktop/graphQL/assets/node_modules/apollo/src/generate.ts:47:3)
at Task.task (/Users/oyb/Desktop/graphQL/assets/node_modules/apollo/src/commands/codegen/generate.ts:211:40)
at Promise.resolve.then.then.skipped (/Users/oyb/Desktop/graphQL/assets/node_modules/listr/lib/task.js:167:30)
at


Most helpful comment

Please

>All comments

Please

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hashlin picture hashlin  ยท  4Comments

lirbank picture lirbank  ยท  4Comments

u-ashish picture u-ashish  ยท  4Comments

reichhartd picture reichhartd  ยท  4Comments

justinanastos picture justinanastos  ยท  3Comments