-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native schema stitching #953
Comments
Each "node" of a Graphene is an ObjectType, so I think there isn't specifics things to achieve to "assemble" multiple schema togethers.
So add something else is not more than create a new ObjectType and add it as a "field" in Query Is it what you are looking for ? |
Schema stitching is the process of creating a single GraphQL schema from multiple underlying remote GraphQL APIs. We don't have that capability in |
@ekampf Thanks for the clarification. Is there any implementation of this problem in python? Even at graphql-core level. I am looking for a naive approach to stich the the types. Something along the lines of ( This is just a prototype, not complete). I basically want a way to combine objects coming from different schemas to one master schema. for schema_type_name, schema_type in child_schema.get_type_map().items(): |
@arindam04 we don't have such an implementation in Python. An alternative solution would be to put an Apollo Server as a proxy in front of your python server just for sticking purposes |
BTW @arindam04 schema stitching in Apollo has been deprecated (and replaced by a new architecture: https://blog.apollographql.com/apollo-federation-f260cf525d21). |
This is actually a something fairly needed in order to integrate Graphene with other Graphql services. |
@anlauren as explained here it is not currently possible to add directives at the type level and won't be until it is supported in graphql-js. Until then I think your only option would be use something like https://github.com/mirumee/ariadne which lets you build your GraphQL server using SDL. |
@jkimbo Are those features not included with ariadne ? is their a package that adds them ? |
@japrogramer I’m not familiar with Ariadne so you’d have to raise an issue the repo to get those answers. |
As this seems to suggest`` custom directives are not yet implemented in Ariadne. |
@anlauren like this.
|
@japrogramer yes but then my graphene server needs to implement the "federation" protocol in order to respond to that set up that Apollo gateway. |
So i have given it a go anyways, it seems that the above works combined to this code added to your schema in graphene:
So that can work with the old way of doing schema stiching, but for federation we'd need to get creative 🤔 |
So, after a bit of workaround I came accross a way to hack Graphene around and actually make the federation protocol work! First, implement my objects. in that example, We define an entity as:
As a side note, in my other service, i define Book that way:
Now you'll need to implement the "federation protocol".
and then add these in a union that is defined in the federationrequirement:
These entities need to be queried, so needs an _entity entry in the graph. This entry is resolving at runtime the type of the entity that we are looking for:
This needs to accept an "any" type that we define like this:
The graph as well needs to be served so the federation service to be aware of it. Following the federation guide, you need to implement an
finally we can define our query and our schema:
And that should work! let me know if you have a more glamorous solution, if i forgot anything in this example |
@anlauren is this a typo
|
@japrogramer oops yes it is, when I cut off my code to make it clearer.
hence the confusion. I'll edit it :) |
Hey, I am also trying to do this, it would be great to get it built it. I've done my own hacks, just adding the
It doesn't handle the entity stuff. I also create two schemas in
because according to the federation spec |
Here is partial and draft implementation of federation specs, based on comments above, with nice api. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi
Can anyone provide an example code how to do schema stitching in python using graphene?
Thanks
The text was updated successfully, but these errors were encountered: