Module: GraphSQL
- Defined in:
- lib/graphsql.rb,
lib/graphsql/mapping.rb,
lib/graphsql/version.rb,
lib/graphsql/resolver.rb,
lib/graphsql/unknown_column_error.rb,
lib/graphsql/aliased_association_error.rb,
lib/generators/graphsql/type/type_generator.rb
Defined Under Namespace
Modules: Generators, Mapping Classes: AliasedAssociationError, Resolver, UnknownColumnError
Constant Summary collapse
- VERSION =
"0.5.0"
Class Method Summary collapse
-
.resolve(relation, lookahead:, type:, required_associations: [], required_columns: []) ⇒ Object
required_associations:/required_columns:name associations/columns the caller needs loaded regardless of what the client requested (e.g. a model's #discussion reading title/body and persona.handle to find_or_open a thread, even when the query didn't ask for those fields).
Class Method Details
.resolve(relation, lookahead:, type:, required_associations: [], required_columns: []) ⇒ Object
required_associations:/required_columns: name associations/columns
the caller needs loaded regardless of what the client requested (e.g. a
model's #discussion reading title/body and persona.handle to
find_or_open a thread, even when the query didn't ask for those
fields). Passing these through here, rather than chaining
.select/.includes onto the return value, is required for
correctness: #resolve returns a plain Array (not a Relation — see
Resolver#resolve_relation) whenever the query also requests a nested
GraphQL-mapped association, and a caller-side .select/.includes
chained after the call silently breaks the moment that happens.
23 24 25 26 27 28 |
# File 'lib/graphsql.rb', line 23 def self.resolve(relation, lookahead:, type:, required_associations: [], required_columns: []) Resolver.new( relation: relation, lookahead: lookahead, type: type, required_associations: required_associations, required_columns: required_columns ).resolve end |