gramps-graphql / gramps--legacy

The core data source combination engine of GrAMPS.
https://gramps.js.org
MIT License
197 stars 13 forks source link

Cannot extend types in data sources #44

Closed grxy closed 6 years ago

grxy commented 6 years ago

In my base data source, I have created a Viewer type that other data sources can choose to extend. My base Viewer type is simply as follows:

type Viewer {
    id: ID!
}

In a different data source, I would like to be able to extend this type using the following syntax:

extend type Viewer {
    test: Float
}

This does not work, however, because each data source is being converted into a schema and then the schemas are being merged. If I just add my additional fields without the extend syntax, the first encountered instance of a type with a given name is used. mergeSchemas accepts an arg onTypeConflict for resolving issues like this, but as far as I can tell, there is no way to pass this in via gramps config. Perhaps this can be added to the config somewhere?

grxy commented 6 years ago

So I've discovered the stitching option for data sources. Digging into that to see if it will work for my use case.

ecwyne commented 6 years ago

This should be done with stitching. I've never created an actual working example for this, but you can see the outline of what it looks like in this comment. https://github.com/gramps-graphql/gramps/issues/2#issuecomment-341153995

The first data-source should be a peerDependency of the second data-source (instead of using the requires property in the example) If you can provide more concrete details or the example (or better yet source code) I'd be happy to help further

grxy commented 6 years ago

@ecwyne I was able to set up extending correctly from within the stitching config. Thanks for pointing me in the right direction.