Skip to content

Commit 4280468

Browse files
authored
Merge pull request #4891 from ryanseys/rs-fix-query
Fix run_graphql_field with missing query string on dummy query
2 parents d9300c4 + 2788b3c commit 4280468

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/graphql/testing/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def initialize(type_name:, field_name:)
4141

4242
def run_graphql_field(schema, field_path, object, arguments: {}, context: {})
4343
type_name, *field_names = field_path.split(".")
44-
dummy_query = GraphQL::Query.new(schema, context: context)
44+
dummy_query = GraphQL::Query.new(schema, "{ __typename }", context: context)
4545
query_context = dummy_query.context
4646
object_type = dummy_query.get_type(type_name) # rubocop:disable Development/ContextIsPassedCop
4747
if object_type

spec/graphql/testing/helpers_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def self.authorized?(object, context)
2828
end
2929

3030
class Student < GraphQL::Schema::Object
31+
def self.authorized?(object, context)
32+
context.errors.empty?
33+
end
34+
3135
field :name, String do
3236
argument :full_name, Boolean, required: false
3337
argument :prefix, String, required: false, default_value: "Mc", prepare: ->(val, ctx) { -> { val.capitalize } }

0 commit comments

Comments
 (0)