graphql-ruby icon indicating copy to clipboard operation
graphql-ruby copied to clipboard

Suppress warning for objectId arguments

Open thomasmarshall opened this issue 1 year ago • 0 comments

Using an argument named objectId currently emits a warning because it redefines the #object_id method. This should technically be safe to do because Ruby doesn't use that method internally, but it still warns because third party code might.

objectId is a valid name for an argument, and a useful one too. This commit suppresses the warning by temporarily setting $VERBOSE to nil while defining the method. It's unlikely any code is relying on the #object_id method for GraphQL input argument objects, but if so it's already broken—this commit just silences the warning.

Host projects could of course suppress the warnings themselves, but it's tricky to do in a localized way when using Schema.from_definition. We'd have to suppress all warnings before calling that, potentially disguising other issues. Ideally GraphQL Ruby would handle this, but let me know if it's not suitable and we can try to work around locally instead.

thomasmarshall avatar Oct 14 '24 10:10 thomasmarshall