Skip to content

stitchSchemas with added fields inserting unneeded Fragment #4262

@cancan101

Description

@cancan101

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions