-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Correctly generate a federated schema when no entity has a @key
.
#985
Conversation
I don't know what the protocol is for marking people who I think would be good to review this, so I'll just do it as a comment: @marwan-at-work I think you're the best one to review this! |
plugin/federation/federation.go
Outdated
@@ -56,9 +56,11 @@ func (f *federation) MutateConfig(cfg *config.Config) error { | |||
"_Any": { | |||
Model: config.StringList{"github.com/99designs/gqlgen/graphql.Map"}, | |||
}, | |||
"Entity": { | |||
} | |||
if len(entityFields) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you consider changing it as follows?
if len(entityFields) > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
b38f728
to
cb79c35
Compare
(I maybe did the wrong thing by amending rather than pushing a new commit, but this is ready for another look!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm :)
Anything else I need to do to help get this merged? I don't understand the 'cover' failure -- it's in an area unrelated to my change, and the diff seems non-contentful to me. Hopefully that's not the thing holding things up, since I don't know what to do about it... |
I believe @vektah could help get this merged :) As for |
I do have a failing test locally:
This differs from the failing test in circleci:
Neither of them should be affected by any code I changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csilvers I tried merge master/HEAD into this changes and test it locally. it passed cover
job.
please rebase onto master/HEAD about this PR.
Normally, when a service is taking part in graphql federation, it will have at least one type defined with a `@key` field, so that other services can link to (that is, have an edge pointing to) the type that this service provides. The previous federation code assumed that was the case. But it's not required: a service could not define `@key` on any of its types. It might seem that would mean the service is unreachable, since there is no possibility of edges into the service, but there are two edges that can exist even without a `@key`: top level Query edges and top level Mutation edges. That is, if a service only provides a top-level query or top-level mutation, it might not need to define a `@key`. This commit updates the federation code to support that use case.
cb79c35
to
fa88499
Compare
I merged and the tests are still failing. I really believe the test failures are not due to my code, but some sort of flakiness. This time it's this:
I don't know what is causing the linker to be killed -- OOM? -- but it looks like that's what's causing the test failure. I don't know if it's possible to just force-rerun the tests, or if it even matters -- I guess we can merge even with the test failure, if we're confident this PR isn't responsible. |
I re-run the tests manually, its passed. |
Correctly generate a federated schema when no entity has a `@key`.
Normally, when a service is taking part in graphql federation, it will
have at least one type defined with a
@key
field, so that otherservices can link to (that is, have an edge pointing to) the type that
this service provides. The previous federation code assumed that was
the case.
But it's not required: a service could not define
@key
on any of itstypes. It might seem that would mean the service is unreachable,
since there is no possibility of edges into the service, but there are
two edges that can exist even without a
@key
: top level Query edgesand top level Mutation edges. That is, if a service only provides a
top-level query or top-level mutation, it might not need to define a
@key
.This commit updates the federation code to support that use case.
Describe your PR and link to any relevant issues.
I have: