Skip to content
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

Fix #1834: Implement federation correctly #1835

Merged
merged 3 commits into from
Jan 22, 2022

Conversation

newerbie
Copy link
Contributor

@newerbie newerbie commented Jan 21, 2022

Fix #1834
Fix #1724
Fix #1090
See also #1192

I have:

  • Added tests covering the bug / feature (see testing)

There are several issues in federation implementation according to the Apollo Federation subgraph specification:

  1. When customizing root query type, _service is not generated in customized query struct. Then Apollo gateway cannot get service definition in subgraph.
  2. If @key directive is not used in graphql schema, both _service and _entities are not generated.

What did you expect?

  1. _service is generated in customized query struct.
  2. _service is generated in any case, while _entities is generated only when @key directive exists.

Minimal graphql.schema and models to reproduce

schema {
    query: CustomQuery
}

type Hello {
  name: String!
}

type CustomQuery {
  hello: Hello!
}

versions

  • gqlgen version 0.15.1
  • go version 1.17
  • dep or go modules? go modules

@coveralls
Copy link

coveralls commented Jan 21, 2022

Coverage Status

Coverage decreased (-0.09%) to 74.909% when pulling 78a0aea on newerbie:master into 9866507 on 99designs:master.

@StevenACoffman
Copy link
Collaborator

Hi! It looks like you need to run cd example; go generate ./... and commit the changes

@newerbie
Copy link
Contributor Author

Hi! It looks like you need to run cd example; go generate ./... and commit the changes

Hi, I just reorganized the code related to line break generation, and after ran cd example; go generate ./..., nothing changed in all generated.go files, thanks for the tip.

@newerbie
Copy link
Contributor Author

Hi! It looks like you need to run cd example; go generate ./... and commit the changes

Hi, I just reorganized the code related to line break generation, and after ran cd example; go generate ./..., nothing changed in all generated.go files, thanks for the tip.

I am so sorry it failed at lint stage again. I checked go:generate throughout the project, and ran go generate ./... again, there were two added line breaks in plugin/federation/testdata/entityresolver/generated/exec.go. I think it's ok now.

@StevenACoffman StevenACoffman merged commit 3fb5fd9 into 99designs:master Jan 22, 2022
@StevenACoffman
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants