Closed rmosolgo closed 5 years ago
As a first step I'll take a stab at adding support for extend ...
to the lexer and parser.
Have there been any latest thoughts on implementing this?
I have a system of many microservices, each implementing their own GQL schema. These schemas are stitched together in a gateway service that exposes all of the queries / mutations to clients in one convenient schema. extend
would help greatly in allowing me to define resolvers that return types from another service's schema!
Example:
# Defined in service A
type User {
id: ID!
name: String!
}
extend type Account {
user: User!
}
# Defined in service B
type Account {
id: ID!
type: String!
}
extend type User {
accounts: [Account]!
}
I'm not super familiar with the inner workings of this gem, but I'll start digging in and seeing what needs to be added to make this happen!
EDIT: Digging into this a bit more, I realized I don't even know what the DSL would look like for this. I'm going to take a stab at what exactly we might want to support with this.
Hi! No, as far as I know, there hasn't been more thought in implementing it. Personally, I don't use the Schema.from_definition
feature, so I don't work on it much 😬. (Although I know plenty of folks use it for their whole schema!)
After implementing the lexer/parser pieces of extend
, I remember taking a look at GraphQL.js to see how extend
works there. Reading the implementation one thing that seemed important is that extending a schema should not alter the existing instance of the schema, but rather return a new schema. I probably won't have time to implement the rest of this in the near future, but I'd happily help review any PR that adds this functionality.
I don't have plans to work on this, so I'm closing this issue. It'd definitely be a nice addition to the library, though!
The GraphQL SDL has a concept of "extending" type definitions, for example:
http://facebook.github.io/graphql/June2018/#sec-Object-Extensions
Should we support this in GraphQL-Ruby? I have heard several folks who use
Schema.from_definition
to build their schemas, would this be helpful?