Implementation of federated graphs
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
No support for federated graphs
Proposal
@apollo/federation
uses a custom property in resolvers for referencing, just like when resolving a property.
Currently @nestjs/graphql
have a @ResolveProperty()
decorator, and what I propose is a @ResolveReference()
decorator explicitly for when using @apollo/federation
Example of how they use __resolveReference
:
const { ApolloServer, gql } = require('apollo-server');
const { buildFederatedSchema } = require('@apollo/federation');
const typeDefs = gql`
type Query {
me: User
}
type User @key(fields: "id") {
id: ID!
username: String
}
`;
const resolvers = {
Query: {
me() {
return { id: "1", username: "@ava" }
}
},
User: {
__resolveReference(user, { fetchUserById }){
return fetchUserById(user.id)
}
}
};
const server = new ApolloServer({
schema: buildFederatedSchema([{ typeDefs, resolvers }])
});
What is the motivation / use case for changing the behavior?
https://www.apollographql.com/docs/apollo-server/federation/introduction
Links
https://www.apollographql.com/docs/apollo-server/api/apollo-federation/
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Introduction to Apollo Federation - Apollo GraphQL Docs
An implementation that keeps the code for a given feature in a single subgraph and separated from unrelated concerns; A product-centric schema with...
Read more >The what, when, why, and how of federated GraphQL
Design and implementation. Implementing a federated graph architecture involves: The different graph servers or schemas; A gateway that unifies ...
Read more >Why Your Organization Needs a Federated Graph Interface
Strong separation of concerns is the first benefit of implementing a Federated Graph Interface. This concept from computer science advocates ...
Read more >Implementing Federated GraphQL Microservices using Apollo ...
Implement a single distributed data graph across multiple services without creating any dependencies using Apollo federation. Learn more about it here.
Read more >Federated GraphQL & Apollo Federation with microservices
“Though there is only one graph, the implementation of that graph should be federated across multiple teams.”.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Haven’t yet done any documentation, but essentially you’d be using
GraphQLGatewayModule
for your API gateway andGraphQLFederationModule
for your microservices.Check out my PR https://github.com/nestjs/graphql/pull/301
And here’s an example of how you’d be using it https://github.com/marcus-sa/nest-graphql-microservices-example/tree/dev?files=1
@marcus-sa oh sorry about I added credits to you. I basically used it in my project and decided to make it a lib so others can easily use it until there is support for federation here. Besides I was working on it, saw your project, wasn’t much difference, took the part I needed and used it internally and decided to share it so others can use until support here (You copy-pasted from nestjs/graphql), I even added support for typegraphql, while true I copied some piece of your work which you made public to copy for free, it was not COPY PASTE. However again my bad for not adding credits to you, besides it was just a temporary fix. and not too different from what I made before only my approach was almost replacing the nest graphql library