Ruby subservices
Ruby subservices — Schema Stitching documentation.
This example demonstrates Ruby subservices within a stitched schema. Their GraphQL implementations use:
- graphql-ruby for GraphQL execution.
- graphql-ruby-schema-directives for class-based schema directives.
GraphQL::Schema.from_definitionfor parsing SDL strings into executable schemas.
Local setup
Clone the GitHub repo.
Then in a new terminal tab:
The following services are available for interactive queries:
- Stitched gateway: http://localhost:4000/graphql
Summary
Try fetching some data:
Unique to this example is that the subservices are Ruby applications. Their GraphQL implementations use graphql-ruby paired with graphql-ruby-schema-directives to generate schema stitching SDLs.
This example demonstrates both schemas built with a code-first approach (as Ruby classes), and by parsing a type definitions string into a schema. Either approach works fine for providing an annotated SDL to schema stitching.
Class-based schemas
The Accounts and Review services are implemented using class-based schema definitions:
The GraphQL::SchemaDirectives gem provides API extensions for applying custom schema directives to
types and fields.
Schemas from type definitions
The Products service is implemented with a parsed type definitions string:
You’ll need to build your own default resolver for this approach. It’s more of a self-service effort, although you remain in control of the complete resolution process.