Add graphql base types
This commit is contained in:
parent
d2fdaacb5d
commit
9bb52dfb8c
8 changed files with 47 additions and 0 deletions
4
app/graphql/mutations/base_mutation.rb
Normal file
4
app/graphql/mutations/base_mutation.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Mutations
|
||||
class BaseMutation < GraphQL::Schema::Mutation
|
||||
end
|
||||
end
|
4
app/graphql/types/base_enum.rb
Normal file
4
app/graphql/types/base_enum.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Types
|
||||
class BaseEnum < GraphQL::Schema::Enum
|
||||
end
|
||||
end
|
4
app/graphql/types/base_input_object.rb
Normal file
4
app/graphql/types/base_input_object.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Types
|
||||
class BaseInputObject < GraphQL::Schema::InputObject
|
||||
end
|
||||
end
|
5
app/graphql/types/base_interface.rb
Normal file
5
app/graphql/types/base_interface.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module Types
|
||||
module BaseInterface
|
||||
include GraphQL::Schema::Interface
|
||||
end
|
||||
end
|
4
app/graphql/types/base_object.rb
Normal file
4
app/graphql/types/base_object.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Types
|
||||
class BaseObject < GraphQL::Schema::Object
|
||||
end
|
||||
end
|
4
app/graphql/types/base_scalar.rb
Normal file
4
app/graphql/types/base_scalar.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Types
|
||||
class BaseScalar < GraphQL::Schema::Scalar
|
||||
end
|
||||
end
|
4
app/graphql/types/base_union.rb
Normal file
4
app/graphql/types/base_union.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
module Types
|
||||
class BaseUnion < GraphQL::Schema::Union
|
||||
end
|
||||
end
|
18
app/graphql/types/url.rb
Normal file
18
app/graphql/types/url.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Types
|
||||
class URL < Types::BaseScalar
|
||||
description "A valid URL, transported as a string"
|
||||
|
||||
def self.coerce_input(input_value, context)
|
||||
url = URI.parse(input_value)
|
||||
if url.is_a?(URI::HTTP) || url.is_a?(URI::HTTPS)
|
||||
url
|
||||
else
|
||||
raise GraphQL::CoercionError, "#{input_value.inspect} is not a valid URL"
|
||||
end
|
||||
end
|
||||
|
||||
def self.coerce_result(ruby_value, context)
|
||||
ruby_value.to_s
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue