rmosolgo / graphql-ruby

Ruby implementation of GraphQL
http://graphql-ruby.org
MIT License
5.38k stars 1.39k forks source link

schema-first support for defining types #3121

Closed karneyli closed 4 years ago

karneyli commented 4 years ago

The library defaults to a code-first approach (e.g. developers define ruby type classes, resolvers, etc and generate a schema artifact post). Code-first has some inherent advantages, notably the schema and the code cannot be out of sync and no schema vs code duplication (if code-generation is used to generate ruby classes).

One notable advantage to schema-first is it allows developers to operate at the contract level, this affords client and server side developers to work at the same time instead of waiting for the server to be completed. The schema-first approach also makes it possible to provide mock data for the API so the client can be tested independently.

Has there been discussion about supporting schema-first approach in the library?

rmosolgo commented 4 years ago

Hey, thanks for the great question. This library has some support for parsing a schema from the GraphQL SDL, described here: https://graphql-ruby.org/schema/sdl.html

I haven't worked on it a ton because I don't have a practical use case, but I've heard of big orgs with big schemas run that way! Anyhow, hope that helps. If you have specific questions or suggestions regarding SDL support, please don't hesitate to ask or open a PR :+1: