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

@oneOf directive support #319

Open
leonardehrenfried opened this issue Feb 12, 2024 · 7 comments
Open

@oneOf directive support #319

leonardehrenfried opened this issue Feb 12, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@leonardehrenfried
Copy link

Describe the problem

We would like to use @oneOf in our schema but magidoc fails to build the documentation with the following error:

Load GraphQL Schema [FAILED: Unable to extract a GraphQL introspection from provided schema: Error: Unknown directive "@oneOf".

Describe the proposed solution

We would be ok if magidoc would simply ignore it. We can add support for it later.

Importance

Would make my life easier

@pelletier197
Copy link
Collaborator

Seems like this is a built-in directive and GraphQL.js should support it out of the box. It should only be a matter of upgrading GraphQL.js and deploying a new version. I'll look into that.

@leonardehrenfried
Copy link
Author

That would be fantastic!

@pelletier197
Copy link
Collaborator

I have just released 4.1.3. Let me know if this works for you now 🙂. I have tried it on my side and it seemed to work fine.

@leonardehrenfried
Copy link
Author

Thanks!

@optionsome can you try this?

@optionsome
Copy link

optionsome commented Feb 12, 2024

Thanks for the quick reply and reaction @pelletier197 . Unfortunately, I tried with newer version now and the issue still persists. I can fix the issue by defining the directive in the schema file but with native GraphQL directives it shouldn't be necessary (although not quite sure what is the current status of this directive).

For context, our configuration of the introspection is as follows:

introspection: {
    type: 'sdl',
    paths: ['src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls'],
  }

@pelletier197
Copy link
Collaborator

pelletier197 commented Feb 12, 2024

Well I don't know why it worked earlier, must have made a mistake. But you're right, it doesn't work. This is a bit out of my control, it seems like this is a quite recent addition to GraphQL-JS. It might not have been released yet. Last release seems to have been done in September.

Would you mind posting the definition you used here for the directive for reference ? I'll make sure to update GraphQL library as soon as a new version is out. Until then, if your solution works, I don't have another solution to offer unfortunately.

@optionsome
Copy link

Ok thank you for the information. The directive definition I used in the schema to get rid of the problem was:

"""
Exactly one of the fields on an input object must be set and non-null while all others are omitted.
"""
directive @oneOf on INPUT_OBJECT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants