Sha256: 5525f15baefdb4ebeeeea6e7fb09d9f523badf03a4b748fdee4e6d55f08b0582
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true require "spec_helper" ExecuteSuite = GraphQL::Compatibility::ExecutionSpecification.build_suite(GraphQL::Execution::Execute) LazyExecuteSuite = GraphQL::Compatibility::LazyExecutionSpecification.build_suite(GraphQL::Execution::Execute) describe GraphQL::Execution::Execute do describe "null propagation on mutation root" do module MutationNullTestRoot INTS = [] def self.push(args, ctx) if args[:int] == 13 nil else INTS << args[:int] args[:int] end end def ints INTS end end let(:root) { MutationNullTestRoot } let(:query_str) do <<-GRAPHQL mutation { one: push(int: 1) thirteen: push(int: 13) two: push(int: 2) } GRAPHQL end before do MutationNullTestRoot::INTS.clear end describe "when root fields are non-nullable" do let(:schema) { GraphQL::Schema.from_definition <<-GRAPHQL type Mutation { push(int: Int!): Int! } type Query { ints: [Int!] } GRAPHQL } it "propagates null to the root mutation and halts mutation execution" do res = schema.execute(query_str, root_value: root) assert_equal [1], MutationNullTestRoot::INTS assert_equal(nil, res["data"]) end end describe 'mutation fields are nullable' do let(:schema) { GraphQL::Schema.from_definition <<-GRAPHQL type Mutation { push(int: Int!): Int } type Query { ints: [Int!] } GRAPHQL } it 'does not halt execution and returns data for the successful mutations' do res = schema.execute(query_str, root_value: root) assert_equal [1, 2], MutationNullTestRoot::INTS assert_equal({"one"=>1, "thirteen"=>nil, "two"=>2}, res["data"]) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
graphql-1.5.4 | spec/graphql/execution/execute_spec.rb |
graphql-1.5.3 | spec/graphql/execution/execute_spec.rb |
graphql-1.4.5 | spec/graphql/execution/execute_spec.rb |