Sha256: 8179d9892ef52d896bd45c832ad5e90870eeddb0f8f7dae26a45b4d61fde250b

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

<%= schema_name %> = GraphQL::Schema.define do
<% if options[:relay] %>
  # Relay Object Identification:

  # Return a string UUID for `object`
  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)
  }

  # Given a string UUID, find the object
  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
    # ...
  }

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-1.8.1 lib/generators/graphql/templates/schema.erb
graphql-1.8.0 lib/generators/graphql/templates/schema.erb