Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor query_executor_spec.rb: use schema def APIs instead of raw_sdl. #179

Draft
wants to merge 1 commit into
base: myron/improve-perf/refactor-query-type
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GraphQL
before(:context) do
self.schema_artifacts = generate_schema_artifacts do |s|
s.object_type "Color" do |t|
t.root_query_fields plural: "ignored"
t.field "id", "ID"
t.field "red", "Int"
t.field "green", "Int"
Expand All @@ -34,19 +35,22 @@ class GraphQL
t.index "alt_colors"
end

# The tests below require some custom GraphQL schema elements that we need to define by
# hand in order for them to be available, so we use `raw_sdl` here for that.
s.raw_sdl <<~EOS
input ColorArgs {
red: Int
}
s.factory.new_input_type "ColorArgs" do |t|
t.field "red", "Int"
s.state.register_input_type(t)
end

type Query {
float: Float # so the Float type exists
colors(args: ColorArgs): [Color!]!
colors2(args: ColorArgs): [Color2!]!
}
EOS
s.on_built_in_types do |type|
if type.name == "Query"
type.field "float", "Float" # so the Float type exists
type.field "colors", "[Color!]!" do |f|
f.argument "args", "ColorArgs"
end
type.field "colors2", "[Color2!]!" do |f|
f.argument "args", "ColorArgs"
end
end
end
end
end

Expand Down