I have a simple graphql-ruby mutation:
class Mutations::User::Destroy < Mutations::BaseMutation
argument :confirm, GraphQL::Types::Boolean, required: true
payload_type GraphQL::Types::Boolean
def resolve(confirm:)
true
end
end
The parent module for this mutation is:
module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
# ....
In a spec, I have the following:
let(:destroy_query) do
%(
mutation UserDestroy($input: DestroyInput!) {
userDestroy(input: $input)
}
)
end
it "works" do
post "/graphql", params: {query: destroy_query, variables: {"input" => {"confirm" => true}}}
This query produces an error response from graphql-ruby:
{"errors"=>[{"extensions"=>{"problems"=>[{"explanation"=>"Could not coerce value \"true\" to Boolean"...estroyInput! was provided invalid value for confirm (Could not coerce value \"true\" to Boolean)"}]}
However, when I tested the query in Apollo Studio, it worked fine. I'm not able to pass the true value in the query here. Is this a bug or am I doing something wrong? I'm considering changing the argument type to something custom, like a YES string. But if someone knows of a different approach, I would appreciate the insight. Thank you.
I don't see how DestroyInput comes in as being in use.
I would call it this way
You've titled something "DestoryInput", but you never created an attribute type to describe it. What is being called "DestroyInput?"