Closed Kwadz closed 4 years ago
I have the same problem. It looks like these are added by apollo-federation and apollo-gateway assumes they are always there.
If you're trying to forward to a third-party graphql, that won't work :(
I find myself in the same situation, it would be nice if we didn't have to do this, especially since some of these 3rd party graphql services are behind walls we don't control :(
I wound up implementing it with the "deprecated" schema stitching. It turns out that there's nothing preventing you from doing that, except that the necessary helpers now live in graphq-tools
.
All you're doing is creating a Link, using that to fetch and wrape the remote schema, turning it into a local schema, and then merging it with your or other schemas. As long as you don't need the "foreign key" functionality of federation, this should always work.
Therefore I think the docs should be updated to mention this.
I had the same and it really defeats what I needed. I just want to setup a simple gateway to route requests and merge results and thought that is what gateway was for.
@wmertens Do you have any examples or good places to explain how to do the stitching?
@ztolley actually the documentation is still valid, and only needed some slight tweaks #3449
I found an excellent article and created a proof of concept that works perfectly. So I'll stick with stitching for now until it's supported by Sangria, Graphene and all the other libraries, not just Apollo
The downstream services in a federated architecture must implement the federation specification.
Many GraphQL servers have already implemented the federated specification already, including graphql-java
, Ariadne, WPGraphQL and Graphene (via graphene-federation
). Others are discussing it, including Sangria, quite recently.
@abernix why can't the federation support be optional, and if it's missing the assumption is that all federation metadata is empty, so federation falls back to simple stitching?
@Kwadz FWIW, I abandoned using Drupal/GraphQL in favor of wrapping the Drupal RestUI module with Apollo Rest DataSource. I also wrapped another 3rd party api with the same package, works much better for our team than mucking around in PHP 🤷♂
Apollo Rest Datasources can be wrapped with the "buildFederatedSchema" function from the Apollo Federation package, automatically configuring the federation specification for you.
Running into this issue now with faunadb downstream. Very annoying.
For anyone still struggling with this, check out: https://github.com/0xR/graphql-transform-federation
Which makes good use of graphl-tools
for remote schemas to make it possible to seamlessly federate and augment schemas not designed for Apollo.
Your mileage might vary, but thanks to that project, I've been able to bring a complex remote schema on board of our federated graph. Took me just a couple of hours.
FYI for anyone stumbling into this and trying to figure it out. That project is out of date and doesn't work with latest Apollo libraries. I'm going to try to take that and see if I can re-engineer it so that I can federate over an existing schema (which I can't change) with latest Apollo server + Gateway
I'm using Apollo Federation to connect to a GraphQL server made with Drupal GraphQL.
So I configured the gateway:
But when I start the server I get: