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

Validate incoming orphan_types are object types #4869

Merged
merged 6 commits into from
Mar 19, 2024
Merged

Conversation

rmosolgo
Copy link
Owner

@rmosolgo rmosolgo commented Mar 4, 2024

Closes #4858

After this change, only Object types may be passed to orphan_types(...). This is how it's supposed to work, although it may break some edge cases. The ways I addressed this in tests are:

  • Using extra_types(...) to attach random types to the schema
  • Adding fields so that types are in the schema
  • Calling add_type_and_traverse(types, root: false), which is a private method and I can't guarantee it will always work. But it's the right thing for implementing Schema.load_from_definition, etc.

@rmosolgo rmosolgo added this to the 2.2.12 milestone Mar 4, 2024
@swalkinshaw
Copy link
Collaborator

swalkinshaw commented Mar 4, 2024

The one slight edge case to this is an interface implementing another interface. This would make it more explicit when you have to pass orphan types from one interface to another. But I still believe this change is better because as is, it obscures how GraphQL actually works. To get around this, people could do orphan_types(*SomeInterface::ORPHAN_TYPES)

@rmosolgo
Copy link
Owner Author

rmosolgo commented Mar 6, 2024

I think this will be a bigger change than I realized -- I'm going to punt it back to 2.3.0.

@rmosolgo rmosolgo modified the milestones: 2.2.12, 2.3.0 Mar 6, 2024
@rmosolgo rmosolgo merged commit d100174 into master Mar 19, 2024
12 checks passed
@rmosolgo rmosolgo deleted the validate-orphan-types branch March 19, 2024 21:27
thomasmarshall added a commit to thomasmarshall/graphql-stitching-ruby that referenced this pull request Apr 6, 2024
GraphQL Ruby 2.3.0 validates incoming orphan_types are object types [1].
One of the suggested fixes is to use `add_type_and_traverse` directly,
though that is a private method and not guaranteed to always work.

[1]: rmosolgo/graphql-ruby#4869
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

Successfully merging this pull request may close these issues.

Validation for orphan types
2 participants