smallrye-graphql
smallrye-graphql copied to clipboard
WIP: Integrate Federation Into Schema Builder
Initial PR for #521
Sorry for not coming back to this earlier, I was on vacation. How far do you think you are? I'm just exploring the code a bit.
Sorry for not coming back to this earlier, I was on vacation. How far do you think you are? I'm just exploring the code a bit.
Sorry for the late reply.
Not too far, I was trying to replace the event listening on io/smallrye/graphql/federation/impl/Federation.java:111
into an explicit call to generate the federated schema before the schema is build on io/smallrye/graphql/bootstrap/Bootstrap.java:174
.
@shmulik-klein: the federation topic is getting more traction in my current project. Can you find some time to work on this in the near future? I completely understand how limited time is.
@t1 I added another pr at https://github.com/t1/graphql-federation-demo/pull/6.
There is still a problem left. On start up, there is a crash at https://github.com/smallrye/smallrye-graphql/blob/12ea1257a46c68c90851b59eaa53b92ce22340b2/server/federation/runtime/src/main/java/io/smallrye/graphql/federation/impl/Federation.java#L144 The problem is the line above https://github.com/smallrye/smallrye-graphql/blob/12ea1257a46c68c90851b59eaa53b92ce22340b2/server/federation/runtime/src/main/java/io/smallrye/graphql/federation/impl/Federation.java#L143 Without it, the war demo does work again. Do we need this for something, or could we remove it?
For Quarkus there is a second problem (maybe more). The Federation.class needs the jandex index. The index is created in the quarkus extension https://github.com/quarkusio/quarkus/blob/e24742a2f3da1572e7529dfd67b36f90abc7f704/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java#L209 and stored in the ScanningContext But when it is needed it is not there anymore since we have a different current. Do you maybe have an idea how to fix this, or who could have an idea?
@robp94 Just an idea: if https://github.com/quarkusio/quarkus/issues/20802 is fixed
a configuration like
quarkus.smallrye-graphql.events.enabled=true
quarkus.smallrye-graphql.schema-include-scalars=true
quarkus.index-dependency.graphql-federation-runtime.group-id=io.smallrye
quarkus.index-dependency.graphql-federation-runtime.artifact-id=smallrye-graphql-federation-api
quarkus.index-dependency.graphql-federation-api.group-id=io.smallrye
quarkus.index-dependency.graphql-federation-api.artifact-id=smallrye-graphql-federation-api
and maven dependencies like
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-federation-api</artifactId>
<version>1.3.4</version>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-federation-runtime</artifactId>
<version>1.3.4</version>
</dependency>
should fix the quarkus problems on startup.
We discussed this in our regular MP GraphQL meeting. As we will merge the complete federation stuff into the core, some things will get much easier; we probably won't even need a federation specific Quarkus extension. I can't quite get my head around what this will look like, but @phillip-kruger might be better at describing what path we need to follow.
I'm also not sure how we can collaborate on this best, as @shmulik-klein doesn't seem to find the time to work on this, which is perfectly okay. But maybe we can bring this into a mergeable state, merge it and create a new PR. Or should we spawn a branch?
In our project we got a working quarkus server with federation, with some technical tricks like working with a 2nd jandex index and manipulation of the schema in the federation gateway itself. Because of that we find some cases that hat not been working before in Smallrye Federation. I pushed this changes without the 2nd index to https://github.com/smallrye/smallrye-graphql/pull/1135 Maybe it can help.
@t1 - this looks more like what we need to do - update the model to contain info on federation, and use that info in Bootstrap
@jmartisk @phillip-kruger since federation is now supported I think this could be closed.