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

Federation: requiring a field with a list of objects generates invalid code #1861

Closed
arnemolland opened this issue Jan 27, 2022 · 2 comments
Closed
Labels
federation Related to Apollo federation help wanted Extra attention is needed

Comments

@arnemolland
Copy link

What happened?

When extending a federated entity with a field of the array type containing object (not primitives/scalars) and adding a field that requires the array field, gqlgen generate generates invalid code. It looks like the execution context does not have any unmarshaler for the specific type. I'm not sure if this kind of relation is valid in GraphQL or if it's missing in gqlgen.

What did you expect?

When extending a federated entity with a field of the array type containing object (not primitives/scalars) and adding a field that requires the array field, gqlgen generate generates valid code.

Minimal graphql.schema and models to reproduce

type Bar {
  id: Int!
}

extend type Foo @key(fields: "id") {
  id: Int!
  arr: [Bar!]! @external
  xyz: Int! @requires(fields: "arr")
}

Logs

gofmt failed on federation.go: /Users/arne/dev/orgs/gameflow/backend/graph-template-go/graph/generated/federation.go:105:33: expected ')', found ',' (and 1 more errors)
validation failed: packages.Load: /Users/arne/dev/orgs/gameflow/backend/graph-template-go/graph/generated/federation.go:105:33: expected ')', found ','
/Users/arne/dev/orgs/gameflow/backend/graph-template-go/graph/generated/federation.go:105:35: expected ';', found rep
/Users/arne/dev/orgs/gameflow/backend/graph-template-go/graph/generated/federation.go:105:26: invalid operation: ec (variable of type *executionContext) is not an interface

Invalid code

entity.Arr, err = ec.(ctx, rep["arr"])

versions

  • gqlgen version? v0.14.0-dev
  • go version? go version go1.17.6 darwin/arm64
  • dep or go modules ? modules
@bpteam
Copy link

bpteam commented Apr 11, 2022

Still actual for versions

  • gqlgen version? v0.17.2
  • go version? go version go1.17.6 darwin/arm64

@dariuszkuc
Copy link
Contributor

fixed in #2884

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
federation Related to Apollo federation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants