Gql

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\Gql
Since
3.3.0

Class Gql

View source (opens new window)

# Public Methods

Method Description
applyDirectives() Apply directives (if any) to a resolved value according to source and resolve info.
canMutateAssets() Return true if active schema can mutate assets.
canMutateCategories() Return true if active schema can mutate categories.
canMutateEntries() Return true if active schema can mutate entries.
canMutateGlobalSets() Return true if active schema can mutate global sets.
canMutateTags() Return true if active schema can mutate tags.
canQueryAssets() Return true if active schema can query assets.
canQueryCategories() Return true if active schema can query categories.
canQueryDrafts() Return true if active schema can query for drafts.
canQueryEntries() Return true if active schema can query entries.
canQueryGlobalSets() Return true if active schema can query global sets.
canQueryInactiveElements() Return true if active schema can query for inactive elements.
canQueryRevisions() Return true if active schema can query for revisions.
canQueryTags() Return true if active schema can query tags.
canQueryUsers() Return true if active schema can query users.
canSchema() Returns whether the given component is included in a schema, for the given action.
createFullAccessSchema() Creates a temporary schema with full access to the GraphQL API.
eagerLoadComplexity() Shorthand for returning the complexity function for an eager-loaded field.
extractAllowedEntitiesFromSchema() Extracts all the allowed entities from a schema for the given action.
extractEntityAllowedActions() Return a list of all the actions the current schema is allowed for a given entity.
getAllowedSites() Get a list of all allowed sites by Schema\
getFieldNameWithAlias() Looking at the resolve information and the source queried, return the field name or it's alias, if used.
getSchemaContainedEntryTypes() Return all entry types a given (or loaded) schema contains.
getUnionType() Get (and create if needed) a union type by name, included types and a resolver function.
isSchemaAwareOf() Returns whether the given component(s) are included in a schema’s scope.
nPlus1Complexity() Shorthand for returning the complexity function for a field that will generate a single query for every iteration.
prepareTransformArguments() Prepare arguments intended for Asset transforms.
relatedArgumentComplexity() Shorthand for returning the complexity function for a field that will add a single query to execution.
singleQueryComplexity() Shorthand for returning the complexity function for a field that will add a single query to execution.
wrapInNonNull() Wrap a GQL object type in a NonNull type.

# applyDirectives()

Apply directives (if any) to a resolved value according to source and resolve info.

View source (opens new window)

Arguments

  • $source (mixed)
  • $resolveInfo (\GraphQL\Type\Definition\ResolveInfo)
  • $value (mixed)

Returns

mixed

# canMutateAssets()

Since
3.5.0

Return true if active schema can mutate assets.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canMutateCategories()

Since
3.5.0

Return true if active schema can mutate categories.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canMutateEntries()

Since
3.5.0

Return true if active schema can mutate entries.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canMutateGlobalSets()

Since
3.5.0

Return true if active schema can mutate global sets.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canMutateTags()

Since
3.5.0

Return true if active schema can mutate tags.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryAssets()

Return true if active schema can query assets.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryCategories()

Return true if active schema can query categories.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryDrafts()

Since
3.6.8

Return true if active schema can query for drafts.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryEntries()

Return true if active schema can query entries.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryGlobalSets()

Return true if active schema can query global sets.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryInactiveElements()

Since
3.6.8

Return true if active schema can query for inactive elements.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryRevisions()

Since
3.6.8

Return true if active schema can query for revisions.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryTags()

Return true if active schema can query tags.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canQueryUsers()

Return true if active schema can query users.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# canSchema()

Returns whether the given component is included in a schema, for the given action.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws

# createFullAccessSchema()

Since
3.4.0

Creates a temporary schema with full access to the GraphQL API.

View source (opens new window)

Returns

craft\models\GqlSchema

# eagerLoadComplexity()

Since
3.6.0

Shorthand for returning the complexity function for an eager-loaded field.

View source (opens new window)

Returns

callable (opens new window)

# extractAllowedEntitiesFromSchema()

Extracts all the allowed entities from a schema for the given action.

View source (opens new window)

Arguments

Returns

array (opens new window)

# extractEntityAllowedActions()

Return a list of all the actions the current schema is allowed for a given entity.

View source (opens new window)

Arguments

Returns

array (opens new window)

# getAllowedSites()

Since
4.0.0

Get a list of all allowed sites by Schema\

View source (opens new window)

Arguments

Returns

craft\models\Site[]

# getFieldNameWithAlias()

Looking at the resolve information and the source queried, return the field name or it's alias, if used.

View source (opens new window)

Arguments

Returns

string (opens new window)

# getSchemaContainedEntryTypes()

Return all entry types a given (or loaded) schema contains.

View source (opens new window)

Arguments

  • $schema

Returns

craft\models\EntryType[]

# getUnionType()

Get (and create if needed) a union type by name, included types and a resolver function.

View source (opens new window)

Arguments

  • $typeName (string (opens new window)) – The union type name.
  • $includedTypes (array (opens new window)) – The type the union should include
  • $resolveFunction (?callable) – The resolver function to use to resolve a specific type. If not provided, a default one will be used that is able to resolve Craft elements.

Returns

mixed

# isSchemaAwareOf()

Returns whether the given component(s) are included in a schema’s scope.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# nPlus1Complexity()

Since
3.6.0

Shorthand for returning the complexity function for a field that will generate a single query for every iteration.

View source (opens new window)

Returns

callable (opens new window)

# prepareTransformArguments()

Since
3.5.3

Prepare arguments intended for Asset transforms.

View source (opens new window)

Arguments

Returns

array (opens new window), string (opens new window)

# relatedArgumentComplexity()

Since
3.6.7

Shorthand for returning the complexity function for a field that will add a single query to execution.

View source (opens new window)

Arguments

Returns

callable (opens new window)

# singleQueryComplexity()

Since
3.6.0

Shorthand for returning the complexity function for a field that will add a single query to execution.

View source (opens new window)

Returns

callable (opens new window)

# wrapInNonNull()

Wrap a GQL object type in a NonNull type.

View source (opens new window)

Arguments

  • $type (mixed)

Returns

mixed