Module: GraphitiGql
- Defined in:
- lib/graphiti_gql/graphiti_hax.rb,
lib/graphiti_gql.rb,
lib/graphiti_gql/engine.rb,
lib/graphiti_gql/errors.rb,
lib/graphiti_gql/schema.rb,
lib/graphiti_gql/version.rb,
lib/graphiti_gql/schema/util.rb,
lib/graphiti_gql/spec_helper.rb,
lib/graphiti_gql/loaders/many.rb,
lib/graphiti_gql/schema/query.rb,
lib/graphiti_gql/response_shim.rb,
lib/graphiti_gql/log_subscriber.rb,
lib/graphiti_gql/active_resource.rb,
lib/graphiti_gql/loaders/has_one.rb,
lib/graphiti_gql/schema/registry.rb,
lib/graphiti_gql/loaders/has_many.rb,
lib/graphiti_gql/exception_handler.rb,
lib/graphiti_gql/schema/connection.rb,
lib/graphiti_gql/loaders/belongs_to.rb,
lib/graphiti_gql/schema/fields/show.rb,
lib/graphiti_gql/schema/fields/index.rb,
lib/graphiti_gql/schema/fields/stats.rb,
lib/graphiti_gql/loaders/many_to_many.rb,
lib/graphiti_gql/schema/fields/to_one.rb,
lib/graphiti_gql/schema/resource_type.rb,
lib/graphiti_gql/schema/fields/to_many.rb,
lib/graphiti_gql/schema/list_arguments.rb,
lib/graphiti_gql/schema/fields/attribute.rb,
lib/graphiti_gql/loaders/polymorphic_has_many.rb,
lib/graphiti_gql/schema/polymorphic_belongs_to_interface.rb
Overview
TODO: Rushing here so tests are in app and code is gross
Defined Under Namespace
Modules: ActiveRecordAdapterExtras, ActiveRecordManyToManyExtras, ActiveResource, Errors, FilterExtras, Loaders, ManyToManyExtras, PaginateExtras, QueryExtras, ResourceExtras, RunnerExtras, ScopeExtras, SortAliasExtras, SortExtras, SpecHelper, StatsExtras
Classes: Configuration, Engine, Error, ExceptionHandler, LogSubscriber, Schema
Constant Summary
collapse
- VERSION =
"0.2.38"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
65
66
67
|
# File 'lib/graphiti_gql.rb', line 65
def self.config
@config ||= Configuration.new
end
|
69
70
71
|
# File 'lib/graphiti_gql.rb', line 69
def self.configure
yield config
end
|
.entrypoint?(resource) ⇒ Boolean
73
74
75
|
# File 'lib/graphiti_gql.rb', line 73
def self.entrypoint?(resource)
!!resource.graphql_entrypoint
end
|
.run(query_string, variables = {}, context = {}) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/graphiti_gql.rb', line 77
def self.run(query_string, variables = {}, context = {})
if context.empty? && Graphiti.context[:object]
context = Graphiti.context[:object]
end
Graphiti.with_context(context) do
payload = {
query: query_string,
variables: variables,
context: context
}
Graphiti.broadcast("schema.before_execute", payload)
Graphiti.broadcast("schema.execute", payload) do
result = schema.execute query_string,
variables: variables,
context: context
result_hash = result.to_h
payload[:result] = result_hash
result_hash
end
end
end
|
.schema ⇒ Object
61
62
63
|
# File 'lib/graphiti_gql.rb', line 61
def self.schema
@schema ||= schema!
end
|
.schema! ⇒ Object
56
57
58
59
|
# File 'lib/graphiti_gql.rb', line 56
def self.schema!
resources ||= Graphiti.resources.reject(&:abstract_class?)
@schema = Schema.new(resources).generate
end
|