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

Schema Merging Issue with @oneOf Directive #6169

Closed
4 tasks
Noejoaquin opened this issue May 10, 2024 · 3 comments
Closed
4 tasks

Schema Merging Issue with @oneOf Directive #6169

Noejoaquin opened this issue May 10, 2024 · 3 comments

Comments

@Noejoaquin
Copy link

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug
I am developing a new feature using the new @oneOf directive. We currently merge our schemas, but when I attempt to perform the following:

const { loadSchemaSync } = require("@graphql-tools/load");
const { GraphQLFileLoader } = require("@graphql-tools/graphql-file-loader");
const { printSchemaWithDirectives } = require("@graphql-tools/utils");

try {
    console.log('Loading schema files...')
    const schemaFiles = loadSchemaSync("./globToGetSchemas/**/schema.graphql", {
        loaders: [new GraphQLFileLoader()],
    });
    console.log('Beginning write of merged queries...')  
    fs.writeFileSync("merged.graphql", printSchemaWithDirectives(schemaFiles));
} catch (error) {
    console.log("Error: ", error)
}

The following error arises:
Screenshot 2024-05-10 at 12 29 59 PM

The schema in question:

input SomeInput @oneOf {
	scenarioOne: InputOne 
	scenarioTwo: InputTwo
}

input InputOne {
	fieldOne: String!
	fieldTwo: String!
}

input InputTwo {
	fieldOne: String!
}

To Reproduce
Attempt to merge a graphql schema using the @oneOf directive

Expected behavior
Schemas using this directive to be merged without issue

Environment:

  • "@graphql-tools/graphql-file-loader": "^8.0.1", "@graphql-tools/load": "^8.0.2",:
  • NodeJS: v20.11.1

Thank you for taking a look into this! 🙏

@ardatan
Copy link
Owner

ardatan commented May 10, 2024

@oneOf is not part of the GraphQL spec. So you have to add the definition of the directive by yourself just like any other custom directive.

@Noejoaquin
Copy link
Author

Noejoaquin commented May 10, 2024

Ahh okay. I see. I misunderstood where things were and clearly only skimmed things. Got a little lost in all the chains of discussion. My bad and thanks!!

@Urigo
Copy link
Collaborator

Urigo commented May 16, 2024

@Noejoaquin are you using OneOf in production today or have a use case for it?
I would love to meet and learn more about your use case

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

3 participants