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
Federation 2 supported? #982
Comments
We're deciding between Rust and Go to implement GraphQL sub-graphs. The Apollo page lists Rust as having very little Fed2 support: Will this library be updated regularly? Is it production ready? Are there other (preferably official) Rust GraphQL libraries? Related discussion: #922 |
I'll support it when I'm free. 🙂 |
Fair enough. What that means is this project isn't ready for production use. |
I suggest you take a look at the releases, commits and issue board. @sunli829 is generously donating an enormous amount of time to supporting this project, and I for one am very grateful.
https://github.com/async-graphql/async-graphql#whos-using-async-graphql-in-production
That's terribly unfair. Many companies and projects are using it successfully in production. If your particular use-case isn't answered, perhaps you could consider sponsoring the project or contributing to it? |
I am not very familiar with the async-graphql codebase, but I do want to contribute to the community in any way I can here. I think it'd be helpful if we at least have ideas written down about how to implement each of the remaining pieces. looking over the apollo compat list, i think the things we need still are:
the override directive should be pretty straightforward since it only applies to fields; the changes that have been made so far should provide a good example for how to proceed. I managed to find a definition of the tag directive - it's documented here: https://specs.apollo.dev/tag/v0.2/; i think it should be pretty similar to existing directive support as well. ftv1 is almost straightforward as per the apollo documentation: https://www.apollographql.com/docs/federation/metrics/#how-tracing-data-is-exposed-from-a-subgraph the really tricky one is
|
re:
schema @link(url : "https://www.apollographql.com/docs/federation/federation-spec/"){
query: Query
}
directive @link(url: String!) repeatable on SCHEMA
directive @federation__key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
scalar federation__FieldSet
Alternatively, if you import those directive definitions (even without supporting renaming) then you don't need to namespace them anymore, e.g. schema @link(url : "https://www.apollographql.com/docs/federation/federation-spec/", import : ["key", "FieldSet"]){
query: Query
}
directive @link(url: String!, import: [String]) repeatable on SCHEMA
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
scalar FieldSet I am not familiar with |
It was harsh I admit. I appreciate the time that @sunli829 has contributed to this project. I also maintain open source projects and it's a thankless job. Kudos to sunli, I meant no offense to him and others who've contributed to this project. My response was directly to the comment "I'll support it when I'm free". Having used numerous open source libraries, it's painful when a bug is discovered, a fix provided, but the maintainer goes AWOL. There are open PRs that are months and even years old. Yes I could fork this, but that introduces all sorts of downstream problems. |
I have taken a little time to try to implement the override directive ... currently trying to solve some mystifying build issues locally. If I can figure it out I might put up a change over the weekend. ftv1 (subgraph) tracing ... should that be a separate crate, maybe? I've seen that there's already a separate crate for publishing traces to apollo studio directly, maybe the subgraph tracing support should be implemented similarly (if not in the same repo)? @dariuszkuc if you have a chance - re
Would you mind elaborating on the distinction (if there is any)? How does federation treat the two differently? I see that your example uses Either way, the issue is figuring out how to configure it for printing. It only needs to be output as part of the federation schema, right? Maybe it could be added as an optional field on the Schema struct, so that it can be output when printing in federation mode.
i am pretty sure async-graphql does not have anything like this - it appears to be very straightforward in printing the definitions registered in the schema. Overall I still consider link to be the biggest challenge - i.e.
is not actually encouraging given that the subset of functionality that is needed provides some challenges. |
From federation perspective there is no difference as either one ( # using extension you can omit defaults
extend schema @link("foo")
# applying directive on schema directly requires specifying default types
schema @link("foo") {
query: Query
} |
In regards to implementing 1. Link to spec only schema @link(url : "https://specs.apollo.dev/federation/v2.0"){
query : Query
} When we link to the target spec, we have to explicitly namespace* federation directives with directive @link(url: String!) repeatable on SCHEMA
directive @federation__key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
scalar federation__FieldSet Simplest way to support it, is to define your directives as
2. Link to spec and specify custom namespace schema @link(url : "https://specs.apollo.dev/federation/v2.0", as: "fed"){
query : Query
} When using custom namespace you have to explicitly namespace federation types (except for directive @link(url: String!, as: String) repeatable on SCHEMA
directive @fed__key(fields: fed__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
scalar fed__FieldSet IMHO this is somewhat complex to support as it requires dynamic renaming of the types based on the user input. 3. Explicitly import federated types schema @link(url : "https://specs.apollo.dev/federation/v2.0", import : ["@key", "FieldSet"]) {
query: Query
} When explicitly importing types you don't need to rename/namespace any of the underlying types. directive @link(url: String!, import: [String]) repeatable on SCHEMA
directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
scalar FieldSet IMHO this is arguably the easiest to implement as we don't need to rename/namespace any of the underlying types. There is a small drawback that there is a small chance that imported types could conflict with the types defined locally (guessing it generally shouldn't be common). 4. Explicitly import federated types and rename them to avoid collisions schema @link(url : "https://specs.apollo.dev/federation/v2.0", import : [ { name: "@key", as: "@mykey" }, "FieldSet"]) {
query: Query
}
directive @link(url: String!, import: [link_Import]) repeatable on SCHEMA
directive @mykey(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE
scalar FieldSet
# note that Import scalar is imported from different spec, hence the namespace, Import can be either a string or `name/as` value pair.
scalar link__Import Similarly to custom namespacing, IMHO this is pretty complex to support as it requires dynamically renaming types based on user input. Full link support would imply automatically applying namespacing (possibly custom) for non-imported types and providing ability to rename the types to avoid the collision. Minimal functionality to support is option 1 above or option 3. |
just marked my PR ready for review - #1060 it's a simple approach to implementing the link directive that relies on the fact that async-graphql does not presently have any custom schema directive support. (if` in the future such support is added, that addition will need to entirely replace what i've done.) |
Support was released in v4.0.14 🎉 |
I think this can be closed now that the fed2 compatibility is all "green" in the test matrix. I think federated tracing can be a separate feature in the future if folks are looking for that, specifically. |
that makes sense to me @dbanty, especially since federated tracing is probably something that should be implemented as a separate crate. |
Thanks for pushing this over the finish line @raptros !! |
Do async-graphql currently support federation 2 schemas?? For using it with new apollo router built with rust instead of nodejs apollo gateway..
The text was updated successfully, but these errors were encountered: