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

Hasura queries that include a fragment on a union type do not work #9179

Open
arcticmatt opened this issue Nov 3, 2022 · 2 comments
Open
Labels
k/bug Something isn't working t/product-platform

Comments

@arcticmatt
Copy link

arcticmatt commented Nov 3, 2022

Version Information

Server Version: 2.7.0, 2.13.0

Environment

Tried on Cloud and locally (using Docker)

What is the current behaviour?

This is what happens when I hit Hasura (which sits in front of a remote schema)

The response is missing goalAmount

image

What is the expected behaviour?

This is what happens when I hit the remote schema directly (same exact query)

The response returns goalAmount as expected

image

How to reproduce the issue?

See queries in screenshots above

Any possible solutions/workarounds you're aware of?

The query works if you don't have a fragment directly on a union type

Keywords

union,fragment

@arcticmatt arcticmatt added the k/bug Something isn't working label Nov 3, 2022
@arcticmatt
Copy link
Author

@adas98012 any update on this?

@ben-white-openx
Copy link

@arcticmatt I might be running into the same issue, curious if you can reproduce this.

I can run a query that references the members of the union, with or without fragment syntax (my union type here is union UnionFoo = FooStandalone | FooShadow):

{
  Foo(limit: 10) {
    __typename
    ...on FooStandalone { id name }
    ...on FooShadow { id name }
  }
}

or

{
  Foo(limit: 10) {
    __typename
    ...FooStandaloneFragment
    ...FooShadowFragment
  }
}
fragment FooStandaloneFragment on FooStandalone { id name }
fragment FooShadowFragment on FooShadow { id name }

Remote GraphQL service receives:

query: 'query  { Foo(limit: 10) { __typename  ... on FooShadow{ id  name  } ... on FooStandalone{ id  name  } } }'

So far, so good.

However I get the same as you if I reference the union type itself - the fields are omitted from the delegated query:

{
  Foo(limit: 10) {
    __typename
    ...on UnionFoo {
      ... on FooStandalone {
        id
        name
      }
      ... on FooShadow {
        id
        name
      }
    }
  }
}

or

{
  Foo(limit: 10) {
    __typename
    ...UnionFooFragment
  }
}

fragment UnionFooFragment on UnionFoo {
  ...FooStandaloneFragment
  ...FooShadowFragment
}
fragment FooStandaloneFragment on FooStandalone { id name }
fragment FooShadowFragment on FooShadow { id name }

Remote GraphQL service receives:

query: 'query  { Foo(limit: 10) { __typename  } }' }

So this is happening for me whenever a union type is referenced in the selection set, not just via a fragment.

(Incidentally I'm generating these queries from an AST with print - so I can't enforce the inline syntax.)

We're on Hasura server v2.15.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/bug Something isn't working t/product-platform
Projects
None yet
Development

No branches or pull requests

3 participants