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

Allow union match with base interface #115

Open
robbss opened this issue Oct 10, 2024 · 0 comments
Open

Allow union match with base interface #115

robbss opened this issue Oct 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@robbss
Copy link

robbss commented Oct 10, 2024

Is your feature request related to a problem? Please describe.

When selecting a union type, it's not possible to match via a base interface, this prevents us from matching on Error to determine if any error happened.

Describe the solution you'd like
Given the schema:

interface Error {
  message: String!
}

type NotFoundError implements Error {
  message: String!
  code: String!
}

union UpdateTripError = NotFoundError

type UpdateTripPayload {
  trip: Trip
  errors: [UpdateTripError!]
}

I would like to be able to generate a query equivalent to:

updateTrip($input) {
  trip {
    comment
  }
  errors {
    ... on Error {
      message
    }
  }
}
graphClient.Mutation(q => q.UpdateTrip(..., o => new { Error = o.Errors(oo => oo.On<Error>().Select(ooo => ooo.Message)) }));

This is currently not possible, due to Error not being part of the union type UpdateTripError.

The query does work when queried directly against the GraphQL backend.

@robbss robbss added the enhancement New feature or request label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant