Sha256: d3ae68883190608df1077ba32118844d962b4c0bfc11daadc219d9ff9d83f9d6

Contents?: true

Size: 821 Bytes

Versions: 61

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Query::Result do
  let(:query_string) { '{ __type(name: "Cheese") { name } }' }
  let(:schema) { Dummy::Schema }
  let(:result) { schema.execute(query_string, context: { a: :b }) }

  it "exposes hash-like methods" do
    assert_equal "Cheese", result["data"]["__type"]["name"]
    refute result.key?("errors")
    assert_equal ["data"], result.keys
  end

  it "is equal with hashes" do
    hash_result = {"data" => { "__type" => { "name" => "Cheese" } } }
    assert_equal hash_result, result
  end

  it "tells the kind of operation" do
    assert result.query?
    refute result.mutation?
  end

  it "exposes the context" do
    assert_instance_of GraphQL::Query::Context, result.context
    assert_equal({a: :b}, result.context.to_h)
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/graphql/query/result_spec.rb
graphql-1.9.11 spec/graphql/query/result_spec.rb
graphql-1.9.10 spec/graphql/query/result_spec.rb
graphql-1.9.9 spec/graphql/query/result_spec.rb
graphql-1.9.8 spec/graphql/query/result_spec.rb
graphql-1.9.7 spec/graphql/query/result_spec.rb
graphql-1.9.6 spec/graphql/query/result_spec.rb
graphql-1.9.5 spec/graphql/query/result_spec.rb
graphql-1.9.4 spec/graphql/query/result_spec.rb
graphql-1.9.3 spec/graphql/query/result_spec.rb
graphql-1.9.2 spec/graphql/query/result_spec.rb
graphql-1.8.17 spec/graphql/query/result_spec.rb
graphql-1.8.16 spec/graphql/query/result_spec.rb
graphql-1.9.1 spec/graphql/query/result_spec.rb
graphql-1.9.0 spec/graphql/query/result_spec.rb
graphql-1.8.15 spec/graphql/query/result_spec.rb
graphql-1.9.0.pre4 spec/graphql/query/result_spec.rb
graphql-1.8.14 spec/graphql/query/result_spec.rb
graphql-1.9.0.pre3 spec/graphql/query/result_spec.rb
graphql-1.9.0.pre2 spec/graphql/query/result_spec.rb