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

Error generating resolvers for federated schema with interface fields in @key #3002

Open
carldunham opened this issue Apr 11, 2024 · 0 comments

Comments

@carldunham
Copy link
Contributor

What happened?

Attempting to use a field from an interface in @key results in a SIGSEGV during code gen.

What did you expect?

Proper code gen.

Minimal graphql.schema and models to reproduce

See the simple schema change at carldunham@3379526.

extend type Query {
    topProducts(first: Int = 5): [Product]
}

interface Producter {
    id: String!
}

type Manufacturer implements Producter @key(fields: "id") {
    id: String!
    name: String!
}

type Product @key(fields: "manufacturer { id } id") @key(fields: "upc") {
    id: String!
    manufacturer: Producter!
    upc: String!
    name: String!
    price: Int!
}

Run go generate ./...

See the error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x10090daf0]

goroutine 1 [running]:
github.com/99designs/gqlgen/plugin/federation/fieldset.fieldByName(0x1009d2902?, {0x140001f40f6, 0x2})
        /Users/carl.dunham/src/gqlgen/plugin/federation/fieldset/fieldset.go:177 +0x20
github.com/99designs/gqlgen/plugin/federation/fieldset.Field.TypeReference({0x14000132ec0, 0x2, 0x140001f40d1?}, 0x3?, {0x140003bec00, 0xb, 0x14000d796a8?})
        /Users/carl.dunham/src/gqlgen/plugin/federation/fieldset/fieldset.go:78 +0x80
github.com/99designs/gqlgen/plugin/federation.(*federation).GenerateCode(0x1400007da70, 0x140000ee0b0)
        /Users/carl.dunham/src/gqlgen/plugin/federation/federation.go:308 +0x1048
github.com/99designs/gqlgen/api.Generate(0x14000151448, {0x0, 0x0, 0x0?})
        /Users/carl.dunham/src/gqlgen/api/generate.go:111 +0x9d4
main.main()
        /Users/carl.dunham/src/gqlgen/testdata/gqlgen.go:43 +0x2d8
exit status 2
federation/products/server.go:1: running "go": exit status 1

versions

  • go run github.com/99designs/gqlgen version? v0.17.45-dev
  • go version? go version go1.22.1 darwin/arm64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant