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

Inline fragments override, rather than merge, response objects #1547

Closed
negz opened this issue Jun 10, 2021 · 0 comments · Fixed by #1663
Closed

Inline fragments override, rather than merge, response objects #1547

negz opened this issue Jun 10, 2021 · 0 comments · Fixed by #1663
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@negz
Copy link

negz commented Jun 10, 2021

What happened?

It appears that objects returned by an inline fragment override the "less specific" part of a query (forgive my limited knowledge of GraphQL terms). I would expect a single, merged object to be returned.

What did you expect?

I expect to be able to make this query:

query {
  kubernetesResource(
    id: "Xf5rXAL-UHvndETH56dPJgA5XXvndEQ5PV9DOf4zbf43O1X_Bzg1MDkxNzM"
  ) {
    metadata {
      name
    }
    ...on ProviderRevision {
      metadata {
        uid
      }
    }
  }
}

And get this result:

{
  "data": {
    "kubernetesResource": {
      "metadata": {
        "name": "crossplane-provider-aws-3b7ef8509173",
        "uid": "3c3d2f11-cf1a-4f49-8e53-88a1110a352c"
      }
    }
  },
  "extensions": {}
}

Instead the inline fragment appears to supercede the previous part of the query and I get only the UID:

{
  "data": {
    "kubernetesResource": {
      "metadata": {
        "uid": "3c3d2f11-cf1a-4f49-8e53-88a1110a352c"
      }
    }
  },
  "extensions": {}
}

I can't immediately find anything in the GraphQL spec that covers how this should be handled, but the fact that the below query returns my expected (merged) object makes me think this might be a bug in gqlgen's handling of inline fragments:

query {
  kubernetesResource(
    id: "Xf5rXAL-UHvndETH56dPJgA5XXvndEQ5PV9DOf4zbf43O1X_Bzg1MDkxNzM"
  ) {
    metadata {
      name
    }
    metadata {
      uid
    }
  }
}

Minimal graphql.schema and models to reproduce

See:

versions

  • gqlgen version? 5ad012e
  • go version? go version go1.16.4 linux/amd64
  • dep or go modules? Modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants