Sha256: 5e8824142a08fba2c3c5ec5e834955c2a859862f23c42af66f33663b75f88000

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

# Comment
class <%= class_name %>AdminSchema < GraphQL::Schema
  use GraphQL::Tracing::NewRelicTracing, set_transaction_name: true
  use GraphqlDevise::SchemaPlugin.new(
    query: Types::Query::AdminUserQueryType,
    mutation: Types::Mutation::AdminUserMutationType,
    resource_loaders: [
      GraphqlDevise::ResourceLoader.new(AdminUser, only: %i[login logout])
    ]
  )

  mutation(Types::Mutation::AdminUserMutationType)
  query(Types::Query::AdminUserQueryType)

  use GraphQL::Batch

  # Union and Interface Resolution
  def self.resolve_type(_abstract_type, _obj, _ctx)
    # TODO: Implement this function
    # to return the correct object type for `obj`
    raise(GraphQL::RequiredImplementationMissingError)
  end

  # Relay-style Object Identification:

  # Return a string UUID for `object`
  def self.id_from_object(object, type_definition, _query_ctx)
    # Here's a simple implementation which:
    # - joins the type name & object.id
    # - encodes it with base64:
    GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id)
  end

  # Given a string UUID, find the object
  def self.object_from_id(id, _query_ctx)
    # For example, to decode the UUIDs generated above:
    type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id)
    #
    # Then, based on `type_name` and `id`
    # find an object in your application
    # ...
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
graphql_scaffold_fan-0.2.5 lib/generators/templates/admin_schema.haml
graphql_scaffold_fan-0.2.4 lib/generators/templates/admin_schema.haml
graphql_scaffold_fan-0.2.3 lib/generators/templates/admin_schema.haml