-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
GraphQL::Client::ValidationError raised with global arguments method #1775
Comments
Weird! Are those two lines the whole backtrace? |
Adding a
|
Woah, it's somehow called from the load-schema-from-JSON code. I have no idea 😆 |
The problem comes from the excessive use of # @return [Hash<String => GraphQL::Schema::Argument] Arguments defined on this thing, keyed by name. Includes inherited definitions
def arguments
inherited_arguments = ((
self.is_a?(Class) &&
!(superclass === Object) &&
superclass.respond_to?(:arguments)
) ? superclass.arguments : {})
# Local definitions override inherited ones
inherited_arguments.merge(own_arguments)
end Now that can't be right. I would expect none of this code needing to call methods on |
It's implementing argument "inheritance", so if you have: class BaseInputObject < GraphQL::Schema::InputObject
end
class EntityInput < BaseInputObject
argument :id, ID, required: true,
description: "The ID of the entity to update"
end
class TitledEntityInput < EntityInput
argument :title, String, required: false
end
class PostInput < TitledEntityInput
argument :body, String, required: false
end Then, PostInput should "inherit" argument configurations from its parents, for example: PostInput.arguments.keys
# [:id, :title, :body] That's why it traverses |
Why wouldn't it just store these in an inheritable class attribute? Example: mongoid/mongoid-history#227 |
Hmm, I took a look at the diff there, it looks like it's using Rails class_attribute, right? How would that work with merging hashes down the inheritance chain? I can't quite see it in my mind's eye 🤔 |
Sorry, I don't have a clear understanding of how to fix this, and I haven't heard any other reports of it, so I'm going to close this issue. If someone else encounters it, please let me know! |
Coming from ashkan18/graphlient#47 I ran into a really weird problem trying to build a command line tool that queries the Github GraphQL API and uses https://github.com/davetron5000/gli. As soon as I tried to do anything with arguments in the tool I got strange
GraphQL::Client::ValidationError
errors. The code looked like this:Here's a minimal repro without GLI.
This is obviously incorrect, the field accepts a login argument. Looks like graphql-ruby is calling
arguments
on Object? It probably shouldn't.The text was updated successfully, but these errors were encountered: