class GraphQL::Schema::Schema

Overview

Represents a GraphQL Schema against which queries can be executed.

Included Modules

Defined in:

graphql-crystal/schema/schema.cr
graphql-crystal/schema/schema_execute.cr

Constant Summary

GRAPHQL_FIELDS = [{:__typename, "", args, ""}, {:types, "", args, ""}, {:directives, "", args, ""}, {:subscriptionType, "", args, ""}, {:queryType, "", args, ""}, {:mutationType, "", args, ""}] of Tuple(Symbol, String, Hash(String, String) | ::Nil, String)
ScalarTypes = { {"String", "A String Value"}, {"Boolean", "A Boolean Value"}, {"Int", "An Integer Number"}, {"Float", "A Floating Point Number"}, {"ID", "An ID"} }

Descriptions for Scalar Types

Constructors

Instance Method Summary

Macro Summary

Instance methods inherited from module GraphQL::ObjectType

graphql_type graphql_type, resolve_field(name, arguments, context) resolve_field

Instance methods inherited from class Object

debug debug

Constructor Detail

def self.new(document : Language::Document) #

Takes a parsed GraphQL schema definition


Instance Method Detail

def add_input_type(name : String, type : InputType.class) #

register a Struct to parse query variables name : the name of the GraphQL Input Type that gets parsed type : the Struct Type to parse the JSON into (has to have the class method from_json see https://crystal-lang.org/api/0.23.1/JSON.html#mapping%28properties%2Cstrict%3Dfalse%29-macro) for more infos


[View source]
def directive_definitions : Hash(String, GraphQL::Language::DirectiveDefinition) #

[View source]

[View source]
def execute(params = ExecuteParams, context = Context.new(self, max_depth)) #

execute a query against the schema params: the Hash with main data context: optional a custom context to be injected in

       field callbacks.

[View source]
def execute(document : Language::Document, params, operation_name : String? = nil, context = Context.new(self, max_depth)) #

execute a query against the schema document: a parsed query params: optional the query variables as Hash or JSON::Any operation_name: optional the query or mutation name to be executed context: optional a custom context to be injected in

       field callbacks.

[View source]
def execute(document : String, params = nil, operation_name : String? = nil, context = Context.new(self, max_depth)) #

execute a query against the schema document: a string representing the query to be executed params: optional the query variables as a Hash operation_name: optional the query or mutation name to be executed context: optional a custom context to be injected in

       field callbacks.

[View source]
def execute(document : Language::Document, params : Hash(String, JSONType)?, operation_name : String?, context = Context.new(self, max_depth)) #

execute a query against the schema document: a parsed query params: optional the query variables as a Hash operation_name: optional the query or mutation name to be executed context: optional a custom context to be injected in

       field callbacks.

[View source]
def max_depth(max_depth) #

[View source]
def max_depth : Int32? #

[View source]
def mutation_resolver : GraphQL::ObjectType? #

[View source]
def mutation_resolver=(mutation_resolver) #

[View source]
def query_resolver : GraphQL::ObjectType? #

[View source]
def query_resolver=(query : ObjectType) #

Wrap the Root Query in the IntrospectionObject to intercept calls to __schema and __type field


def query_resolver=(query_resolver) #

[View source]
def resolve(&block) #

[View source]
def resolve_field(name : String, arguments, context : GraphQL::Schema::Context) #

resolve a named field on this object with query arguments and context


def type_resolve(type : String | Language::AbstractNode) #

get a type definition


[View source]
def types : Hash(String, GraphQL::Language::TypeDefinition) #

[View source]
def wrap_cb(resolved : ObjectType) #

[View source]

Macro Detail

macro field(name, &block) #

macro field(name, description, args, typename, &block) #

macro inject #

macro injection #