Shopify / tapioca

The swiss army knife of RBI generation
MIT License
729 stars 121 forks source link

Feature request: generating types from a graphql.schema file for use with graphql-client #1232

Open snoble opened 1 year ago

snoble commented 1 year ago

It would be really nice to be able to have types for inputs and results for graphql-client and it feels like it just requires gluing together some existing pieces of code.

A file of graphql queries can be parsed into a Document with GraphQL.parse. https://github.com/rmosolgo/graphql-ruby/blob/a08c86f097395e27272fdead5037d7b3ef03401e/lib/graphql.rb#L45

And then the tapioca graphq_type_helper can be used to map the graphql types to sorbet types. https://github.com/Shopify/tapioca/blob/main/lib/tapioca/dsl/helpers/graphql_type_helper.rb

And then you'd want to produce an rbi file that will provide types for the queries produced by GraphQL::Client#parse to be used with GraphQL::Client#query.

bdewater-thatch commented 1 year ago

https://github.com/github/graphql-client/pull/305 might be of interest!

qubyte commented 7 months ago

The above link is dead. Should it point somewhere else now? Edit: Looks like this: https://github.com/github-community-projects/graphql-client/pull/7