Skip to content

@graphql-tools/stitch doesn't preserve @oneOf #1404

@jwhitaker-gridcog

Description

@jwhitaker-gridcog

Hey guys, thanks for maintaining the tools herein.

We've noticed that stitchSchemas doesn't seem to preserve @oneOf. Repro:

import {stitchSchemas} from '@graphql-tools/stitch';
import {buildSchema, printSchema} from 'graphql';

const schemaSrc = `
type Query {
  findPerson(in: FindPersonInput): Person
  findPersonById(id: String): Person @deprecated(reason: "use findPerson")
}

type Person {
  Name: String
  ID: String
}

input FindPersonInput @oneOf {
  byId: String
  byName: String
}
`;

const schema = buildSchema(schemaSrc);
const stitchedSchema = stitchSchemas({subschemas: [schema]});

console.log(printSchema(schema));
console.log('-----------')
console.log(printSchema(stitchedSchema));

Output:

type Query {
  findPerson(in: FindPersonInput): Person
  findPersonById(id: String): Person @deprecated(reason: "use findPerson")
}

type Person {
  Name: String
  ID: String
}

input FindPersonInput @oneOf {
  byId: String
  byName: String
}
-----------
type Query {
  findPerson(in: FindPersonInput): Person
  findPersonById(id: String): Person @deprecated(reason: "use findPerson")
}

type Person {
  Name: String
  ID: String
}

input FindPersonInput { # <--- missing @oneOf!
  byId: String
  byName: String
}

Any reason why this is the case? I've included a @deprecated as a demo of another built-in directive that seems to work out of the box.

Cheers!

package.json:

{
  "name": "stitchbug",
  "version": "1.0.0",
  "description": "",
  "license": "ISC",
  "dependencies": {
    "@graphql-tools/stitch": "^9.4.28",
    "graphql": "^16.11.0"
  },
  "devDependencies": {
    "tsx": "^4.20.5",
    "typescript": "^5.9.2"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions