Sha256: b9c3f6baa29f8c8fff5e5bf52c1575f2ea0409917ec2291b9d92adf5524d9b3f

Contents?: true

Size: 1000 Bytes

Versions: 10

Compression:

Stored size: 1000 Bytes

Contents

<%= schema_name %> = GraphQL::Schema.define do
  query(Types::QueryType)
<% 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 -> (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

10 entries across 10 versions & 1 rubygems

Version Path
graphql-1.6.4 lib/generators/graphql/templates/schema.erb
graphql-1.5.15 lib/generators/graphql/templates/schema.erb
graphql-1.6.3 lib/generators/graphql/templates/schema.erb
graphql-1.6.2 lib/generators/graphql/templates/schema.erb
graphql-1.6.1 lib/generators/graphql/templates/schema.erb
graphql-1.6.0 lib/generators/graphql/templates/schema.erb
graphql-1.5.14 lib/generators/graphql/templates/schema.erb
graphql-1.5.13 lib/generators/graphql/templates/schema.erb
graphql-1.5.12 lib/generators/graphql/templates/schema.erb
graphql-1.5.11 lib/generators/graphql/templates/schema.erb