Sha256: 0237b47c6d1247dab440a9b237f7eefe05801dc4676b1d47afcf4c8931bc917a

Contents?: true

Size: 1.24 KB

Versions: 16

Compression:

Stored size: 1.24 KB

Contents

class <%= schema_name %> < GraphQL::Schema
  query(Types::QueryType)

  # Opt in to the new runtime (default in future graphql-ruby versions)
  use GraphQL::Execution::Interpreter
  use GraphQL::Analysis::AST

  # Add built-in connections for pagination
  use GraphQL::Pagination::Connections
<% if options[:relay] %>
  # Relay 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

  # Object Resolution
  def self.resolve_type(type, obj, ctx)
    # TODO: Implement this function
    # to return the correct type for `obj`
    raise(GraphQL::RequiredImplementationMissingError)
  end
<% end %><% if options[:batch] %>
  # GraphQL::Batch setup:
  use GraphQL::Batch
<% end %>end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
graphql-1.11.3 lib/generators/graphql/templates/schema.erb
graphql-1.11.2 lib/generators/graphql/templates/schema.erb
graphql-1.10.14 lib/generators/graphql/templates/schema.erb
graphql-1.11.1 lib/generators/graphql/templates/schema.erb
graphql-1.10.13 lib/generators/graphql/templates/schema.erb
graphql-1.11.0 lib/generators/graphql/templates/schema.erb
graphql-1.10.12 lib/generators/graphql/templates/schema.erb
graphql-1.10.11 lib/generators/graphql/templates/schema.erb
graphql-1.10.10 lib/generators/graphql/templates/schema.erb
graphql-1.10.9 lib/generators/graphql/templates/schema.erb
graphql-1.10.8 lib/generators/graphql/templates/schema.erb
graphql-1.10.7 lib/generators/graphql/templates/schema.erb
graphql-1.10.6 lib/generators/graphql/templates/schema.erb
graphql-1.10.5 lib/generators/graphql/templates/schema.erb
graphql-1.10.4 lib/generators/graphql/templates/schema.erb
graphql-1.10.3 lib/generators/graphql/templates/schema.erb