Apollo-tooling: Generating query files with 'typescript' target

Created on 24 Jul 2018  ·  3Comments  ·  Source: apollographql/apollo-tooling

There're errors when I tried to change into .ts with schema.json and schema.graphql
MacdeMBP:src mac$ apollo codegen:generate ./apollo.ts --outputFlat --schema=./schema_dump.json --target=typescript
.../schema_dump.graphql: The bool definition is not executable.
.../schema_dump.graphql: The int64 definition is not executable.
.../schema_dump.graphql: The Message definition is not executable.
.../schema_dump.graphql: The Mutation definition is not executable.
.../schema_dump.graphql: The Query definition is not executable.
.../schema_dump.graphql: The string definition is not executable.
.../schema.graphql: The bool definition is not executable.
.../schema.graphql: The int64 definition is not executable.
.../schema.graphql: The Message definition is not executable.
.../schema.graphql: The Mutation definition is not executable.
.../schema.graphql: The Query definition is not executable.
.../schema.graphql: The string definition is not executable.
.../server.graphql: The Device definition is not executable.
.../server.graphql: Unknown type "number".
.../server.graphql: Cannot query field "device" on type "Query".
✔ Loading Apollo config
✔ Scanning for GraphQL queries (3 found)
✖ 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:97:64)
at Promise.resolve.then.then.skipped (/usr/local/lib/node_modules/apollo/node_modules/listr/lib/task.js:167:30)
at

Most helpful comment

./node_modules/.bin/apollo-codegen generate --queries ./resources/schema/* --schema ./schema.json --output ./generated --target typescript

> error: Unknown argument: queries

I'd also appreciate a few more details on this, at least some proven-to-be-working examples, there seems to be a major lack of those or they are well hidden.

All 3 comments

You need to set your --queries flag so it knows not to consider all .graphql files as queries. Default is **/*.graphql.

Thanks for your answer!When I use --queries ,errors are still there

./node_modules/.bin/apollo-codegen generate --queries ./resources/schema/* --schema ./schema.json --output ./generated --target typescript

> error: Unknown argument: queries

I'd also appreciate a few more details on this, at least some proven-to-be-working examples, there seems to be a major lack of those or they are well hidden.

Was this page helpful?
0 / 5 - 0 ratings