spec/graphql/query/context_spec.rb in graphql-0.10.3 vs spec/graphql/query/context_spec.rb in graphql-0.10.4

- old
+ new

@@ -7,10 +7,14 @@ resolve -> (target, args, ctx) { ctx[args[:key]] } end field :contextAstNodeName, types.String do resolve -> (target, args, ctx) { ctx.ast_node.class.name } end + + field :queryName, types.String do + resolve -> (target, args, ctx) { ctx.query.class.name } + end }} let(:schema) { GraphQL::Schema.new(query: query_type, mutation: nil)} let(:result) { schema.execute(query_string, context: {"some_key" => "some value"})} describe "access to passed-in values" do @@ -29,9 +33,20 @@ query getCtx { contextAstNodeName } |} it 'provides access to the AST node' do expected = {"data" => {"contextAstNodeName" => "GraphQL::Language::Nodes::Field"}} + assert_equal(expected, result) + end + end + + describe "access to the query" do + let(:query_string) { %| + query getCtx { queryName } + |} + + it 'provides access to the AST node' do + expected = {"data" => {"queryName" => "GraphQL::Query"}} assert_equal(expected, result) end end end