Skip to the content
Documentation

exp:expgraphqlenable

No ratings yet

Available since Exponential 6.0.15 (in development, not in a release yet).

Summary

Switch the GraphQL API on in one command: the siteaccesses, the mutations, CORS for a front end, an API key, the schema, a curl example; a dry run unless --apply

Usage

./console exp:expgraphqlenable [options]
php bin/php/expgraphqlenable.php [options]
./console exp:graphql:enable [options]

Aliases

exp:graphql:enable

Help

The output of ./console help exp:expgraphqlenable (the script run with --help), without the standard options:

Usage: bin/php/expgraphqlenable.php [OPTION]...
Switch the GraphQL API on
Sets graphql.ini [GraphQLSettings] Enabled=enabled in settings/override, adds the siteaccesses of
--siteaccess to SiteAccessList[] (without it the API answers in every siteaccess); the mutations
come on with it (MutationsEnabled=enabled, the default), and --mutations writes that too, where
exp:graphql:disable --mutations switched them off. Lets a front end's origin call it with
--origin (rest.ini [CorsSettings]), makes a personal API key for a user with --key-for (the token
is shown once), checks that the schema builds, and prints the end point, a curl example and the
playground. Shows the changes as a diff and writes nothing without --apply; with --apply each file
is backed up first and the INI caches are cleared.

./console exp:graphql:enable                                        what would change
./console exp:graphql:enable --siteaccess=site --apply
./console exp:graphql:enable --siteaccess=site --origin=https://shop.example.com --key-for=frontend --apply
./console exp:graphql:enable --siteaccess=site --mutations --key-for=editor --apply

Exit code: 0 done (or shown); 1 a file could not be written, or the key not made; 3 the library is
missing; 2 wrong options (an unknown siteaccess or user, an origin that is not one).


Options:
  --origin=VALUE    the origin of a front end allowed to call it from a browser (CORS), comma separated
  --mutations       switch the mutations on again (in the siteaccesses of --siteaccess); they are on by default
  --key-for=VALUE   make a personal API key for this user (a login)
  --key-name=VALUE  the name of the key (default: GraphQL front end)
  --scope=VALUE     the scopes of the key: graphql:read (the default), graphql:write (the default with --mutations)
  --days=VALUE      the lifetime of the key in days (rest.ini [ApiKeySettings] ExpiryChoices[]; default 90)
  --apply           write; without it nothing is changed

Options

Option Value Description
--siteaccess required the siteaccesses it answers in, comma separated (default: every siteaccess)
--origin required the origin of a front end allowed to call it from a browser (CORS), comma separated
--mutations - switch the mutations on again (in the siteaccesses of --siteaccess); they are on by default
--key-for required make a personal API key for this user (a login)
--key-name required the name of the key (default: GraphQL front end)
--scope required the scopes of the key: graphql:read (the default), graphql:write (the default with --mutations)
--days required the lifetime of the key in days (rest.ini [ApiKeySettings] ExpiryChoices[]; default 90)
--apply - write; without it nothing is changed

Standard options

Every script also takes the standard options of the script framework: --help, --quiet, --siteaccess, --debug, --colors, --no-colors, --logfiles, --no-logfiles, --verbose and --allow-root-user.

Source

bin/php/expgraphqlenable.php, kernel/private/classes/commands/expgraphqlenable.php

See also

Generated example: exp:expgraphqlenable

Added to the reference for Exponential 6.0.15.

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.