Download the PHP package amazeelabs/graphql_directives without Composer

On this page you can find all versions of the php package amazeelabs/graphql_directives. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package graphql_directives

GraphQL Directives

A directive-based approach to GraphQL schema implementations. Provides a 'Directable' schema plugin that loads a GraphQL schema definition file and implements it using directive plugins.

Usage

Create a GraphQL schema definition file, and annotate it with directives.

Configure a GraphQL server with the "Directable" schema plugin, and set the schema definition path to the created schema file.

Directive definitions will be automatically prepended to the schema. To support IDE's with autocompletion and syntax checking, there is a drush command to generate a schema file with all directives and information where they are implemented.

Chaining

Directives can be chained to combine reusable data producers. They are composed from left to right, meaning the output of the left directive is passed as parent value to its right neighbour.

Mapping

The @map directive allows to map over the output of its left neighbour and apply all directives on the right side to each item.

Default values

Since Drupal's data structures can't guarantee integrity, the graphql schema will enforce default values as much as possible. Whenever a type is used in a non-nullable position (no ! at the end ), it attempts to apply a default value if the value is null. The default value is determined by the type, e.g. 0 for Int, false for Boolean, "" for String and [] for list types like [String!]!.

For custom types, interface, unions or scalars, the @default directive can be used to start a directive chain that generates a default value.

Type resolution

Directives can also be used to resolve the runtime types of unions and interfaces. To do that, apply any directives that can be used to resolve field values to the interface or union. The chain of directives should resolve to a string value which will be treated as a type id.

This resolved type id will then be matched against object types annotated with the @type directive to retrieve the actual type.

Argument handling

Directives can use the ArgumentTrait to apply dynamic arguments. If the directive argument equals $, the current value will be passed as the argument value. If its $, followed by any characters, these characters will be used as a key to retrieve the value from the current query arguments.

Arguments that implement this behaviour are marked to be (dynamic).

Directives

@value

The @value directive allows you to define a static value for a field as primitive or a JSON encoded string. Without any arguments, it will emit null.

@seek

Extracts a value from a list or iterable. The pos argument marks the target position.

@prop

Extracts a property from an object or map. The key argument marks the target key.

@map

Iterate over the current result list and apply the following directives to each item.

@type

Annotate an object type with a specific id that will be used for interface- and union type resolution.

@arg

Retrieve an arguments value and inject it as the current value that will be passed as parent to subsequent directives.

@route

Resolve a path (dynamic) to a Drupal Url object.

@loadEntity

Load Drupal entities in various ways. If there are no arguments, it assumes that the parent value contains a Url object generated by @route, and it attempts to load the entity from there.

If used with id or uuid, an optional operation argument allows to define a specific operation for access checks.

Otherwise, it requires to define a static type argument and either an id (dynamic) or uuid (dynamic) argument.

@resolveEntity[...]

Retrieve various simple properties of an entity. The following directives are supported:

@resolveEntityTranslation

Retrieve as specific translation of an entity, defined by the lang (dynamic) argument.

@resolveEntityTranslations

Retrieve all translations of an entity.

@resolveProperty

Retrieve a property of an entity by its path argument.

@lang

Switch the current execution language for the remaining subtree below the current field. Accepts either a code argument (dynamic) or, if omitted, uses the parent value. If the latter is a string, it will be used as-is, if its an instance of TranslatableInteface, the language is derived from there.

@resolveMenuItems

Retrieve all items of a menu entity. Accepts an optional max_level argument that caps the maximum number of menu levels. The tree is flattened to a list, to avoid the necessity of nested fragments. The @resolveMenuItemId and @resolveMenuItemParentId directives should be used to reconstruct the tree in the consumer. The list of menu items is also filtered by language, respecting the current execution context language, as it can be controlled by @lang.

@resolveMenuItem[...]

Various menu item properties.

@resolveEntityReference & @resolveEntityReferenceRevisions

Resolve referenced entities attached to a given field. Will attempt to retrieve translations matching the current host entity.

@drupalView

Executes a Drupal view.

id argument

View ID and display separated by colon. Example: content_hub:default.

args argument

Filters, page number, etc. in query string format. Example: page=1&pageSize=9&contextualFilters=40/12&tag[]=1&type=foo

Reserved keys:

The rest of keys are taken as filters.

Array values are allowed in the format of NPM query-string package with arrayFormat set to bracket, e.g. tag[]=1&tag[]=2.

Returning result

The structure of the result is the following:

Translations

Use the @lang directive to set the language for the view. If the resulting entities have the chosen language, they will be returned in that language.

If the results have to be filtered by the language, use Content: Translation language (= Interface text language selected for page) filter in the view.

Extending

To add custom directives, create a module and add new Plugins in the src/Plugin/GraphQL/Directive directory. The plugins "id" will be the handle to invoke it in the schema, without the @ prefix.

Autoloading

The @amazeelabs/codegen-autoloader provides a convenient option to add new directives using the drupal mode. The resulting JSON file is compatible to this modules Autoload registry configuration option.

Schema Extensions

The module provides a DirectableSchemaExtensionPluginBase class that can be used to create schema extensions that react to directives in the parent schema definition. A schema extension plugin for the Drupal GraphQL module provides two schema definitions: one for the "base" schema and one for the actual extensions. In case of directable schema extension, the base schema definition should contain the directives while the extension schema defines the derived types and fields.

For a very simple example, please refer to the graphql_directives_test module.


All versions of graphql_directives with dependencies

PHP Build Version
Package Version
Requires webmozart/glob Version ^4.7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package amazeelabs/graphql_directives contains the following files

Loading the files please wait ....