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

[idea] you could use apollo-cli to generate interfaces for graphql queries #70

Open
jeffwillette opened this issue Jul 2, 2018 · 4 comments

Comments

@jeffwillette
Copy link

I am just getting started with converting my gatsby site to typescript and it looks like apollo-cli can generate all the interfaces for the page queries so you don't have to type out the interfaces yourself.

I had success with the following commands

apollo schema:download --endpoint https://localhost:8000/___graphql gatsby-schema.json
apollo codegen:generate --tagName=graphql --queries=./src/pages/**/* --schema=./gatsby-schema.json gatsby-queries.d.ts
@fabien0102
Copy link
Owner

@deltaskelta Great idea! But it's already there ^^ https://github.com/fabien0102/gatsby-starter/blob/master/package.json#L20 it's done by gql-gen, can you tell me if it respond to your need? I don't know if the apollo-cli is better (it was not existing when I made this starter ;) )

@jeffwillette
Copy link
Author

I believe the only difference in apollo is that is actually parses the graphql tags in your files so you get interfaces for your component queries and not just the whole API. This way you wouldn't have to assemble an interface to match the query in every component file.

@fabien0102
Copy link
Owner

It can be a good improvement! I really need to test by myself 👍

If you want to add this command to the starter and replace the actual gql-gen with apollo-cli, I will review/accept your PR with pleasure 😉

@jeffwillette
Copy link
Author

I'd be happy to add it, but it seems there is a current problem with typescript in gatsby that is affecting this. I'll have to wait until I can find a way around that and then I'll add the commands. Here is the issue gatsbyjs/gatsby#5789

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

2 participants