Skip to content

Commit 3b95062

Browse files
committed
Fix test setup
1 parent f2e01ab commit 3b95062

2 files changed

Lines changed: 2 additions & 50 deletions

File tree

lib/graphql/execution/input_values.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ def initialize(query, runner)
1010

1111
def variable_values
1212
@variable_values ||= begin
13-
if @query.selected_operation.nil?
14-
raise <<~TXT
15-
Missing selected_operation: #{@query.query_string.inspect}
16-
17-
#{@query.context.errors.map(&:inspect).join("\n\n")}
18-
TXT
19-
end
2013
variable_nodes = @query.selected_operation.variables
2114
if variable_nodes.empty?
2215
EmptyObjects::EMPTY_HASH

spec/graphql/execution/input_values_spec.rb

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,30 @@ class ExecutionInputValuesTest < Minitest::Test
88
INACTIVE
99
}
1010
11-
input NestedInput {
12-
value: String
13-
nested: NestedInput
14-
}
15-
1611
input TestInput {
1712
string: String
18-
int: Int
1913
float: Float
20-
boolean: Boolean
21-
id: ID
22-
enum: TestStatus
23-
nested: NestedInput
24-
stringList: [String]
25-
nonNullItemList: [String!]
26-
nestedList: [NestedInput]
27-
}
28-
29-
input RequiredFieldsInput {
30-
required: String!
31-
optional: String
32-
}
33-
34-
input ValidatedFieldsInput {
35-
scalar: String
36-
list: [String]
37-
input: ValidatedFieldsInput
38-
inputList: [ValidatedFieldsInput]
39-
}
40-
41-
input OneOfInput @oneOf {
42-
string: String
4314
int: Int
15+
enum: TestStatus
4416
}
4517
4618
type Mutation {
4719
testInput(input: TestInput): Boolean
48-
requiredFields(input: RequiredFieldsInput!): Boolean
49-
argWithDefault(input: String = "fallback-value"): Boolean
50-
oneOf(input: OneOfInput!): Boolean
51-
validates(input: ValidatedFieldsInput!): Boolean
52-
validatesOneArg(a: String, b: String): Boolean
5320
}
5421
5522
type Query {
5623
ping: Boolean
5724
}
5825
|)
5926

60-
TEST_SCHEMA.mutation.fields["validatesOneArg"].tap do |f|
61-
f.validates(required: { one_of: [:a, :b] })
62-
end
63-
64-
TEST_SCHEMA.get_type("ValidatedFieldsInput").tap do |t|
65-
t.arguments["scalar"].validates(length: { minimum: 2 })
66-
t.arguments["list"].validates(length: { minimum: 2 })
67-
end
6827

6928
class DummyRunner
7029
def add_step(s); end
7130
def schema; TEST_SCHEMA; end
7231
end
7332

7433
def get_input_values(variables_string: "", variables: nil)
75-
query_str = "query(#{variables_string}) { __typename }"
34+
query_str = "query#{variables_string ? "(#{variables_string})" : ""} { __typename }"
7635
query = GraphQL::Query.new(TEST_SCHEMA, query_str, validate: false, variables: variables)
7736
GraphQL::Execution::InputValues.new(query, DummyRunner.new)
7837
end

0 commit comments

Comments
 (0)