Sha256: 5a0448c6a1ff1b981b0577258637ff79144ce770520544b11358432c9c5f1c6c

Contents?: true

Size: 891 Bytes

Versions: 13

Compression:

Stored size: 891 Bytes

Contents

require "spec_helper"

describe GraphQL::StaticValidation::MutationRootExists do
  include StaticValidationHelpers

  let(:query_string) {%|
    mutation addBagel {
      introduceShip(input: {shipName: "Bagel"}) {
        clientMutationId
        shipEdge {
          node { name, id }
        }
      }
    }
  |}

  let(:schema) {
    query_root = GraphQL::ObjectType.define do
      name "Query"
      description "Query root of the system"
    end

    GraphQL::Schema.define do
      query query_root
    end
  }

  it "errors when a mutation is performed on a schema without a mutation root" do
    assert_equal(1, errors.length)
    missing_mutation_root_error = {
      "message"=>"Schema is not configured for mutations",
      "locations"=>[{"line"=>2, "column"=>5}],
      "fields"=>["mutation addBagel"],
    }
    assert_includes(errors, missing_mutation_root_error)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql-1.2.6 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.2.5 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.2.4 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.2.3 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.2.2 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.2.1 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.2.0 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.1.0 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-1.0.0 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-0.19.4 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-0.19.3 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-0.19.2 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb
graphql-0.19.1 spec/graphql/static_validation/rules/mutation_root_exists_spec.rb