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

Codegen creates extra code on INPUT_OBJECT directive when using nested input fields? #3009

Open
worldisaduck opened this issue Apr 15, 2024 · 1 comment

Comments

@worldisaduck
Copy link

worldisaduck commented Apr 15, 2024

What happened?

I have following gql schema:

with schema below when I run code gen it creates unmarshaling function with directive function call for flightable_place and non_flightable_place fields which passes parent input object(destination) to my OneOf implementation function, which it should do, but also it does the same for destination field and passes it's parent input object which is main DirectionInput input object to OneOf directive implementation, which it shouldn't because it doesn't make any sense and oneOf directive doesn't get called on DirectionInput

What did you expect?

Am I doing something wrong and what should I expect from following schema?

Minimal graphql.schema and models to reproduce

directive @oneOf on INPUT_OBJECT

input Destination @oneOf {
    flightable_place: FlightablePlace
    non_flightable_place: NonFlightablePlace
}

input FlightablePlace {
    iata: String!
}

input NonFlightablePlace {
    uuid: String!
}

input DirectionInput {
    destination: Destination!
    some_field: String
    some_field2: Int
}

type Query {
   direction(input: QueryInput!): Direction
}

type Direction {
    origin: String
    destination: String
}

versions

  • github.com/99designs/gqlgen v0.17.45
  • 1.22.1
@worldisaduck
Copy link
Author

in other words, codegen generates directive call as if there was @oneOf directive on DirectionInput as well

input DirectionInput @oneOf {
    destination: Destination!
    some_field: String
    some_field2: Int
}

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