-
Notifications
You must be signed in to change notification settings - Fork 11
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 mandatory field is not working #24
Comments
Can you provide steps to reproduce? |
I believe the If schema refresh is not enabled, then the non-mandatory service would never actually join the federation if the service was not running during init. In which case it might be better for the user if gateway exits if any of the services are unavailable during init. |
Non-mandatory should not throw if missing during init. |
import fastify from 'fastify';
import mercurius from 'mercurius';
import fastifyCors from 'fastify-cors';
const init = (opts = {logger:{level:"error"}}) => {
const gateway = fastify(opts);
gateway.register(fastifyCors);
gateway.register(mercurius, {
graphiql: "playground",
gateway: {
services: [
{
name: 'appointments',
url: 'http://localhost:4002/graphql',
mandatory: true
},
{
name: 'invoice',
url: 'http://localhost:4001/graphql',
mandatory: false
},
{
name: 'profile',
url: 'http://localhost:4004/graphql',
mandatory: false
},
{
name: 'search',
url: 'http://localhost:4003/graphql',
mandatory: false
},
],
},
});
return gateway;
}
if (require.main === module) {
init().listen(4000);
}
export default init;``` |
And the federated service is as follows: import fastify from 'fastify';
import mercurius from 'mercurius';
import fastifyCors from 'fastify-cors';
import { typeDefs } from './schema';
import { resolvers } from './resolvers';
const init = (opts = {logger:{level:"error"}}) => {
const app = fastify(opts);
app.register(fastifyCors);
app.register(mercurius, {
graphiql: "playground",
schema: typeDefs,
resolvers,
federationMetadata: true
});
return app;
}
if (require.main === module) {
init().listen(4001);
}
export default init;``` |
@mcollina the docs for the mandatory flag mentioned that one service is necessary does that mean I need at least 1 mandatory service? |
Maybe @asciidisco or @pscarey might help you more. |
It's not really possible to further debug your problem with the code samples you uploaded, not for a problem which contains that much variables like the one you're describing... To elaborate a it further on the To answer your specific question, yes, at least one service needs to be I hope that clarifies things a bit. As said, your specific problem can't be solved without a minimal test-case I'm afraid. |
@asciidisco here is the sample code https://github.com/pashamo/federation-test |
@asciidisco did you get a chance to look into the test case? |
@nabsofken Not until now; I scheduled some time within the next 2 days to do so; will get back to you with more details once I have them. At a first glance, your code looks fine. |
@nabsofken So, I was able to check your problem. What doesn't work, if the service isn't online & responding at the federation startup, the whole thing bails out. This seems to be due to the fact, that the I've checked your code against the So it should be classified as a bug, reason is that the @nabsofken you think you could provide a PR with a fix? |
This mandatory flag would be awesome feature, if only gateway could start without mandatory services, otherwise it is absolutely not usable because we can not trust the flag and have to implement schema querying for each service before starting up the gateway. All services becomes hard dependencies. E.g. non-mandatory service is down and gateway pod restarting at that time. |
When starting a federated service with one non mandatory federated service down, the entire federated service doesn't start. This is the error I see:
The text was updated successfully, but these errors were encountered: