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

Union with types from different service implementing value type interface #361

Closed
mpospelov opened this issue Jun 18, 2020 · 0 comments · Fixed by #2259
Closed

Union with types from different service implementing value type interface #361

mpospelov opened this issue Jun 18, 2020 · 0 comments · Fixed by #2259

Comments

@mpospelov
Copy link
Contributor

  • Package name: apollo-gateway occurs on master and latest versions

  • Here a commit with failing test:

    type Query {
      content: [Content!]!
    }
    union Content = Video | Article
    type Article implements WebResource @key(fields: "id") {
      id: ID
      url: String
    }
    extend type Video @key(fields: "id") {
      id: ID @external
    }
    interface WebResource {
      url: String
    }
    interface WebResource {
      url: String
    }
    type Video implements WebResource @key(fields: "id") {
      id: ID
      url: String
    }
    • query via gateway with
    query {
      content {
        ... on WebResource {
          url
        }
      }
    }
    • the expected result is
    { 
      data:{
        content: [
          { url: 'https://foobar.com/articles/1' },
          { url: 'https://foobar.com/videos/1' },
        ]
      }
    }
    • the actual result is
    { 
      data:{
        content: [
          { url: 'https://foobar.com/articles/1' },
          { url: null },
        ]
      }
    }
    • Query plan:
     QueryPlan {
        Fetch(service: "contentService") {
          {
            content {
              __typename
              ... on WebResource {
                url
              }
            }
          }
        },
     }
    • it ignores querying the Video service for some reason, I believe that such cases should detect services which implements the interface to prevent this issue 🤔
  • Runnable reproduction:

    1. clone my branch https://github.com/mpospelov/apollo-server/tree/union-with-interfaces-issue
    2. run jest -- packages/apollo-gateway/src/__tests__/integration/unions-with-value-interfaces.test.ts

Thank you for all the hard work! 🔥🚀

@abernix abernix transferred this issue from apollographql/apollo-server Jan 15, 2021
pcmanus pushed a commit to pcmanus/federation that referenced this issue Nov 18, 2022
As we build the query graph, some edges are added between abstract types
to avoid type explosion when we can. Unfortunately, in some cases,
adding those edge was incorrect and we need to type-explode due to
some specific different between subgraphs on the definition of the
types involved. This fixes this issue.

Fixes apollographql#361
pcmanus pushed a commit that referenced this issue Nov 18, 2022
As we build the query graph, some edges are added between abstract types
to avoid type explosion when we can. Unfortunately, in some cases,
adding those edge was incorrect and we need to type-explode due to
some specific different between subgraphs on the definition of the
types involved. This fixes this issue.

Fixes #361

Co-authored-by: Mikhail Pospelov <[email protected]>
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

Successfully merging a pull request may close this issue.

1 participant