module GraphQL::ObjectType

Overview

module to be included or extended by Classes and Modules to make them act as GraphQL Objects. Provides the field Macro for defining GraphQL Type Fields.

class MyType
  getter :name
  def initialize(@name : String, @email : String); end

  includes GraphQL::ObjectType
  field :name  # with no further arguments
               # the field will resolve to
               # the getter method of the
               # same name

  field :email { @email } # a block can be provided
                          # to access instance vars

  # a block will be called with an arguments hash
  # and the context of the graphql request
  field :signature do |args, context|
    "#{@name} - #{args[

Direct including types

Defined in:

graphql-crystal/types/object_type.cr

Instance Method Summary

Macro Summary

Instance Method Detail

def graphql_type #

get the GraphQL name of this object. defaults to the class name


[View source]
def resolve_field(name, arguments, context) #

This method gets called when a field is resolved on this object. The method gets automatically created for every ObjectType


[View source]

Macro Detail

macro graphql_type(name) #

setter can be used to set GraphQL name of the Object. Defaults to the class name. Is used in introspection queries


[View source]
macro graphql_type(&block) #

setter that takes a block. can be used to set GraphQL name of the Object. Defaults to the class name. Is used in introspection queries.


[View source]