add graphql endpoint
This commit is contained in:
0
app/graphql/mutations/.keep
Normal file
0
app/graphql/mutations/.keep
Normal file
9
app/graphql/mutations/base_mutation.rb
Normal file
9
app/graphql/mutations/base_mutation.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
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
app/graphql/types/.keep
Normal file
0
app/graphql/types/.keep
Normal file
5
app/graphql/types/base_argument.rb
Normal file
5
app/graphql/types/base_argument.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseArgument < GraphQL::Schema::Argument
|
||||
end
|
||||
end
|
||||
7
app/graphql/types/base_connection.rb
Normal file
7
app/graphql/types/base_connection.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseConnection < Types::BaseObject
|
||||
# add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
|
||||
include GraphQL::Types::Relay::ConnectionBehaviors
|
||||
end
|
||||
end
|
||||
7
app/graphql/types/base_edge.rb
Normal file
7
app/graphql/types/base_edge.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseEdge < Types::BaseObject
|
||||
# add `node` and `cursor` fields, as well as `node_type(...)` override
|
||||
include GraphQL::Types::Relay::EdgeBehaviors
|
||||
end
|
||||
end
|
||||
5
app/graphql/types/base_enum.rb
Normal file
5
app/graphql/types/base_enum.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseEnum < GraphQL::Schema::Enum
|
||||
end
|
||||
end
|
||||
6
app/graphql/types/base_field.rb
Normal file
6
app/graphql/types/base_field.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseField < GraphQL::Schema::Field
|
||||
argument_class Types::BaseArgument
|
||||
end
|
||||
end
|
||||
6
app/graphql/types/base_input_object.rb
Normal file
6
app/graphql/types/base_input_object.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseInputObject < GraphQL::Schema::InputObject
|
||||
argument_class Types::BaseArgument
|
||||
end
|
||||
end
|
||||
10
app/graphql/types/base_interface.rb
Normal file
10
app/graphql/types/base_interface.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
module BaseInterface
|
||||
include GraphQL::Schema::Interface
|
||||
edge_type_class(Types::BaseEdge)
|
||||
connection_type_class(Types::BaseConnection)
|
||||
|
||||
field_class Types::BaseField
|
||||
end
|
||||
end
|
||||
8
app/graphql/types/base_object.rb
Normal file
8
app/graphql/types/base_object.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseObject < GraphQL::Schema::Object
|
||||
edge_type_class(Types::BaseEdge)
|
||||
connection_type_class(Types::BaseConnection)
|
||||
field_class Types::BaseField
|
||||
end
|
||||
end
|
||||
5
app/graphql/types/base_scalar.rb
Normal file
5
app/graphql/types/base_scalar.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseScalar < GraphQL::Schema::Scalar
|
||||
end
|
||||
end
|
||||
7
app/graphql/types/base_union.rb
Normal file
7
app/graphql/types/base_union.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BaseUnion < GraphQL::Schema::Union
|
||||
edge_type_class(Types::BaseEdge)
|
||||
connection_type_class(Types::BaseConnection)
|
||||
end
|
||||
end
|
||||
11
app/graphql/types/mutation_type.rb
Normal file
11
app/graphql/types/mutation_type.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class MutationType < Types::BaseObject
|
||||
# TODO: remove me
|
||||
field :test_field, String, null: false,
|
||||
description: "An example field added by the generator"
|
||||
def test_field
|
||||
"Hello World"
|
||||
end
|
||||
end
|
||||
end
|
||||
8
app/graphql/types/node_type.rb
Normal file
8
app/graphql/types/node_type.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
module NodeType
|
||||
include Types::BaseInterface
|
||||
# Add the `id` field
|
||||
include GraphQL::Types::Relay::NodeBehaviors
|
||||
end
|
||||
end
|
||||
18
app/graphql/types/query_type.rb
Normal file
18
app/graphql/types/query_type.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class QueryType < Types::BaseObject
|
||||
# Add `node(id: ID!) and `nodes(ids: [ID!]!)`
|
||||
include GraphQL::Types::Relay::HasNodeField
|
||||
include GraphQL::Types::Relay::HasNodesField
|
||||
|
||||
# Add root-level fields here.
|
||||
# They will be entry points for queries on your schema.
|
||||
|
||||
# TODO: remove me
|
||||
field :test_field, String, null: false,
|
||||
description: "An example field added by the generator"
|
||||
def test_field
|
||||
context[:current_user].email
|
||||
end
|
||||
end
|
||||
end
|
||||
18
app/graphql/x_stake_schema.rb
Normal file
18
app/graphql/x_stake_schema.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
class XStakeSchema < GraphQL::Schema
|
||||
mutation(Types::MutationType)
|
||||
query(Types::QueryType)
|
||||
|
||||
def self.resolve_type(abstract_type, obj, ctx)
|
||||
raise(GraphQL::RequiredImplementationMissingError)
|
||||
end
|
||||
|
||||
def self.id_from_object(object, type_definition, query_ctx)
|
||||
GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id)
|
||||
end
|
||||
|
||||
def self.object_from_id(id, query_ctx)
|
||||
type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id)
|
||||
type_name.constantize.find(item_id)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user