Class: GQLi::Introspection
- Inherits:
-
Object
- Object
- GQLi::Introspection
- Extended by:
- DSL
- Defined in:
- lib/gqli/introspection.rb
Overview
Introspection schema and validator
Constant Summary collapse
- TypeRef =
Specific type kind introspection fragment
fragment('TypeRef', '__Type') { kind name ofType { kind name ofType { kind name ofType { kind name } } } }
- InputValue =
Input value introspection fragment
fragment('InputValue', '__InputValue') { name description type { ___ TypeRef } defaultValue }
- FullType =
Type introspection fragment
fragment('FullType', '__Type') { kind name description fields(includeDeprecated: true) { name description args { ___ InputValue } type { ___ TypeRef } isDeprecated deprecationReason } inputFields { ___ InputValue } interfaces { ___ TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ___ TypeRef } }
- IntrospectionQuery =
Query for fetching the complete schema
query { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ___ FullType } directives { name description args { ___ InputValue } onOperation onFragment onField } } }
Instance Attribute Summary collapse
-
#mutation_type ⇒ Object
readonly
Returns the value of attribute mutation_type.
-
#query_type ⇒ Object
readonly
Returns the value of attribute query_type.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#subscription_type ⇒ Object
readonly
Returns the value of attribute subscription_type.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(client) ⇒ Introspection
constructor
A new instance of Introspection.
-
#valid?(query) ⇒ Boolean
Returns if the query is valid.
-
#validate(query) ⇒ Object
Returns the evaluated validation for a query.
Methods included from DSL
fragment, fragment, query, query
Constructor Details
#initialize(client) ⇒ Introspection
Returns a new instance of Introspection
81 82 83 84 85 86 87 |
# File 'lib/gqli/introspection.rb', line 81 def initialize(client) @schema = client.execute!(IntrospectionQuery).data.__schema @query_type = schema.queryType @mutation_type = schema.mutationType @subscription_type = schema.subscriptionType @types = schema.types end |
Instance Attribute Details
#mutation_type ⇒ Object (readonly)
Returns the value of attribute mutation_type
79 80 81 |
# File 'lib/gqli/introspection.rb', line 79 def mutation_type @mutation_type end |
#query_type ⇒ Object (readonly)
Returns the value of attribute query_type
79 80 81 |
# File 'lib/gqli/introspection.rb', line 79 def query_type @query_type end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema
79 80 81 |
# File 'lib/gqli/introspection.rb', line 79 def schema @schema end |
#subscription_type ⇒ Object (readonly)
Returns the value of attribute subscription_type
79 80 81 |
# File 'lib/gqli/introspection.rb', line 79 def subscription_type @subscription_type end |
#types ⇒ Object (readonly)
Returns the value of attribute types
79 80 81 |
# File 'lib/gqli/introspection.rb', line 79 def types @types end |
Instance Method Details
#valid?(query) ⇒ Boolean
Returns if the query is valid
95 96 97 |
# File 'lib/gqli/introspection.rb', line 95 def valid?(query) validate(query).valid? end |
#validate(query) ⇒ Object
Returns the evaluated validation for a query
90 91 92 |
# File 'lib/gqli/introspection.rb', line 90 def validate(query) Validation.new(self, query) end |