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

stitchSchemas with added fields inserting unneeded Fragment #4262

Open
Tracked by #5201 ...
cancan101 opened this issue Feb 21, 2022 · 0 comments
Open
Tracked by #5201 ...

stitchSchemas with added fields inserting unneeded Fragment #4262

cancan101 opened this issue Feb 21, 2022 · 0 comments

Comments

@cancan101
Copy link

Describe the bug
I am using stitchSchemas to proxy to a remote QGL API while at the same time adding a new field to one of the types. When my proxy server makes the request to the upstream API, it seems to be inserting an unneeded inline fragment into the query.

To Reproduce
Steps to reproduce the behavior:

Using this code to stitch:

  const ret = stitchSchemas({
    inheritResolversFromInterfaces: true,
    subschemas: [schema],
    typeDefs: /* GraphQL */ `
      extend interface Movie {
        foo: String
      }
      extend type Movie_Type {
        foo: String
      }
    `,
    resolvers: {
      Movie: {
        foo: () => "foo",
      },
    },
  });

and then I query with:

query{
  Movie{
    id
    foo
  }
}

the query sent to the upstream is:

{
  Movie {
    id
    ... on Movie_Type {
      __typename
    }
    __typename
    __typename
  }
}

the schema (once merged) is:

interface Object {
  id: ID!
}

interface BaseObject {
  id: ID!
}

interface Movie {
  id: ID!
  foo: String
}

type Movie_Type implements Movie & Object & BaseObject {
  id: ID!
  foo: String
}

type Query {
  Movie(filter: FilterMovie, order: OrderMovie, first: Int, last: Int, before: String, after: String): [Movie!]
}

Expected behavior
A query sent to upstream looking like:

{
  Movie {
    id
    __typename
  }
}

Environment:

  • OS: MacOS
  • "@graphql-tools/load": "^7.5.1",
  • "@graphql-tools/schema": "^8.3.1",
  • "@graphql-tools/stitch": "^8.4.3",
  • "@graphql-tools/url-loader": "^7.7.1",
  • NodeJS: v15.4.0

Additional context

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