title: GraphQL-Ruby : When executing a mutation, get error Variable $...... is declared by ....(mutation).... but not used
body: <p>I'm cutting my teeth on GraphQL ruby here and this seems like it should be basic but the docs make this very difficult to grok. Where did I go wrong here?</p>
  <p>My goal is simply to make a GraphQL mutation in my Ruby app.</p>
  <p><strong>app/graphql/types/mutation_type.rb</strong></p>
  <pre><code>module Types
    class MutationType &lt; Types::BaseObject
  
      field :name, String
  
      field :create_trip, mutation: Mutations::CreateTrip
    end
  end
  </code></pre>
  <p>Here's the mutation in
  <strong>app/graphql/mutations/create_trip.rb</strong></p>
  <pre><code>class Mutations::CreateTrip &lt; Mutations::BaseMutation
    null true
    argument :leavingFrom, String
  
    field :name, String
  
    type Types::TripType
  
    def resolve(leavingFrom: )
      new_trip = Trip.create(leavingFrom: leavingFrom)
  
      # this doesn't really do anything--- this is proof-of-concept code only
      if new_trip.save
        # Successful creation, return the created object with no errors
        {
          trip: trip,
          errors: [],
        }
      else
        # Failed save, return the errors to the client
        {
          trip: nil,
          errors: trip.errors.full_messages
        }
      end
    end
  end
  </code></pre>
  <p>the <strong>app/graphql/types/trip_type.rb</strong> is</p>
  <pre><code># frozen_string_literal: true
  
  module Types
    class TripType &lt; Types::BaseObject
      field :id, ID, null: false
      field :traveling_party_id, Integer
      field :name, String
    end
  end
  </code></pre>
  <p>When I run this mutation:</p>
  <pre><code>mutation CreateTrip($leavingFrom: String) {
    name
  }
  </code></pre>
  <p>(with some data for leavingFrom)</p>
  <p><strong>I get this unexpected result: &quot;Variable $leavingFrom is declared by CreateTrip but not used&quot;</strong></p>
  <p>Expected result: My mutation calls through to the resolve on my GraphQL mutation.</p>
  <p>I think the problem is in my query, because it does not look like the Ruby code ever called. Contrary to the message itself, the <strong><a href="https://i.stack.imgur.com/R0QcS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R0QcS.png" alt="Ruby variable" /></a></strong> leavingFrom is indeed used by the mutation in the resolve body.</p>