exp:expgraphqlenable
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.
Script bin/php/expgraphqlenable.php, code in kernel/private/classes/commands/expgraphqlenable.php. Run it from the installation root, as the user the web server runs as:
./console exp:expgraphqlenable --help
./console exp:graphql:enable --help
php bin/php/expgraphqlenable.php --helpHelp text
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
| Option | Value | Help |
|---|---|---|
--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 |
Read from the option definitions in the code (startup(), getOptions(), options() or ezcConsoleOption). Every script also takes the standard options of the script framework (--help, --siteaccess, --debug, --quiet, --allow-root-user ...).
Related
Generated by ./console exp:help:examples from bin/php/expgraphqlenable.php, kernel/private/classes/commands/expgraphqlenable.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.