gramps-graphql / gramps--legacy

The core data source combination engine of GrAMPS.

Home Page:https://gramps.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot extend types in data sources

grxy opened this issue · comments

commented

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?

commented

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

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. gramps-graphql/gramps#2 (comment)

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

commented

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