Class: GraphQL::CardSchema

Inherits:
Schema
  • Object
show all
Defined in:
lib/graph_q_l/card_schema.rb

Class Method Summary collapse

Class Method Details

.id_from_object(object, type_definition, query_ctx) ⇒ Object

Return a string UUID for ‘object`



18
19
20
21
22
23
# File 'lib/graph_q_l/card_schema.rb', line 18

def 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

.object_from_id(id, query_ctx) ⇒ Object

Given a string UUID, find the object



26
27
28
29
30
31
32
33
# File 'lib/graph_q_l/card_schema.rb', line 26

def 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

.resolve_type(abstract_type, obj, ctx) ⇒ Object

Union and Interface Resolution

Raises:

  • (GraphQL::RequiredImplementationMissingError)


9
10
11
12
13
# File 'lib/graph_q_l/card_schema.rb', line 9

def resolve_type abstract_type, obj, ctx
  # TODO: Implement this function
  # to return the correct object type for `obj`
  raise GraphQL::RequiredImplementationMissingError
end