mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Ruby: Move GraphQL test to their own directory
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
module Mutations
|
||||
class BaseMutation < GraphQL::Schema::RelayClassicMutation
|
||||
argument_class Types::BaseArgument
|
||||
field_class Types::BaseField
|
||||
input_object_class Types::BaseInputObject
|
||||
object_class Types::BaseObject
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
module Mutations
|
||||
class Dummy < BaseMutation
|
||||
argument :something_id, ID, required: false
|
||||
|
||||
def load_something(id)
|
||||
"Something number #{id}"
|
||||
end
|
||||
|
||||
def resolve(something:)
|
||||
system("echo #{something}")
|
||||
{ success: true }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
module Resolvers
|
||||
class Base < GraphQL::Schema::Resolver
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
module Resolvers
|
||||
class DummyResolver < Resolvers::Base
|
||||
type String, null: false
|
||||
argument :something_id, ID, required: true
|
||||
|
||||
def load_something(id)
|
||||
"Something number #{id}"
|
||||
end
|
||||
|
||||
def resolve(something:)
|
||||
system("echo #{something}")
|
||||
"true"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
module Types
|
||||
class BaseArgument < GraphQL::Schema::Argument
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
module Types
|
||||
class BaseField < GraphQL::Schema::Field
|
||||
argument_class Types::BaseArgument
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
module Types
|
||||
class BaseInputObject < GraphQL::Schema::InputObject
|
||||
argument_class Types::BaseArgument
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
module Types
|
||||
module BaseInterface
|
||||
include GraphQL::Schema::Interface
|
||||
|
||||
field_class Types::BaseField
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
module Types
|
||||
class BaseObject < GraphQL::Schema::Object
|
||||
field_class Types::BaseField
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
module Types
|
||||
class MutationType < Types::BaseObject
|
||||
field :dummy, mutation: Mutations::Dummy
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
module Types
|
||||
class QueryType < Types::BaseObject
|
||||
field :test_field, String, null: false,
|
||||
description: "An example field added by the generator",
|
||||
resolver: Resolvers::DummyResolver
|
||||
|
||||
field :with_arg, String, null: false, description: "A field with an argument" do
|
||||
argument :number, Int, "A number", required: true
|
||||
end
|
||||
def with_arg(number:)
|
||||
system("echo #{number}")
|
||||
number.to_s
|
||||
end
|
||||
|
||||
field :with_method, String, null: false, description: "A field with a custom resolver method", resolver_method: :custom_method do
|
||||
argument :blah_number, Int, "A number", required: true
|
||||
end
|
||||
def custom_method(blah_number:, number: nil)
|
||||
system("echo #{blah_number}")
|
||||
system("echo #{number}")
|
||||
blah_number.to_s
|
||||
end
|
||||
|
||||
field :with_splat, String, null: false, description: "A field with a double-splatted argument" do
|
||||
argument :something, Int, "A number", required: true
|
||||
end
|
||||
def with_splat(**args)
|
||||
system("echo #{args[:something]}")
|
||||
args[:something].to_s
|
||||
end
|
||||
|
||||
field :with_splat_and_named_arg, String, null: false, description: "A field with two named arguments, where the method captures the second via a hash splat param" do
|
||||
argument :arg1, Int, "A number", required: true
|
||||
argument :arg2, Int, "Another number", required: true
|
||||
end
|
||||
def with_splat_and_named_arg(arg1:, **rest)
|
||||
system("echo #{arg1}")
|
||||
system("echo #{rest[:arg2]}")
|
||||
arg1.to_s
|
||||
end
|
||||
|
||||
def foo(arg)
|
||||
system("echo #{arg}")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user