Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for.graphql/yaml schemas #259

Closed
arthens opened this issue Oct 2, 2017 · 3 comments
Closed

Support for.graphql/yaml schemas #259

arthens opened this issue Oct 2, 2017 · 3 comments

Comments

@arthens
Copy link

arthens commented Oct 2, 2017

We are writing a client for a backend that only provides provides schema.graphql (extracted using https://github.com/graphcool/graphql-cli ) and no schema.json, but if we try to use this schema with apollo-codegen we get a parse error

> apollo-codegen generate src/**/*.graphql --schema schema.graphql --target typescript --output schema.ts

(function (exports, require, module, __filename, __dirname) { schema {
                                                                     ^
SyntaxError: Unexpected token {

Does apollo-codegen only support JSON schemas? Any plan to support .graphql schemas in future?

@martijnwalraven
Copy link
Contributor

You can convert a schema.graphql schema file to schema.json using:

apollo-codegen introspect-schema schema.graphql --output schema.json

But it probably makes sense to support schema.graphql as is, especially as more tools start supporting it. We may also want to integrate with graphql-cli directly.

@arthens
Copy link
Author

arthens commented Oct 2, 2017

But it probably makes sense to support schema.graphql as is, especially as more tools start supporting it.

This would be nice, particularly because the .graphql is more human readable.

We may also want to integrate with graphql-cli directly.

Their -w is quite handy. It'd be nice to be able to say "poll for the schema and run apollo-codegen if the schema has changed".

@mike-marcacci
Copy link
Contributor

Another really clean solution would be to let introspect-schema write to stdout and let generate read from stdin; that way you could easily pipe them together.

shadaj added a commit that referenced this issue Jul 9, 2018
shadaj added a commit that referenced this issue Jul 9, 2018
* Support generating based on .graphql schema files

Fixes #259

* Remove unused import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants