3.2.11 • Published 4 years ago

graphql-cli-maana v3.2.11

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Maana Plugin for the GraphQL Command Line

Custom graphql-cli plugin to programmatically interact with a Maana cluster.

All examples assume you are running from a directory with a valid .graphqlconfig file. See below for how to add authentication.

Commands

mload

Upload CSV and JSON files to a Maana cloud instance, with possible NDF conversion.

Note: JSON files must be a collection (array) of instances.

Normalized Document Format

The NDF is an emerging standard used by the Prisma ORM-like layer.

Arguments and Options

  • fileOrDir (required) - specifies a supported file (.csv or .json) or a directory (recursively processed)
    • mutation names are automatically inferred from file names
    • file names should match the (singular) entity name (e.g., person.json) => addPersons (= assumed mutation)
  • -m | --mutation (optional) - explicit mutation to use (for a single file only)
  • -b | --batch (optional) - limit on how many instances to send at time
  • -n | --ndfout (optional) - Normalized Document Format conversion output
  • -t | --type (optional) - explicit typename to use for NDF conversion
  • -p | --project (optional) - project in .graphqlconfig
  • -e | --endpoint (optional) - optional endpoing in .graphqlconfig

Examples

# load all the CSV and JSON files in the data folder using the .graphqlconfig project 'test
gql mload -p test data/

# load a specific file
gql mload -p test data/person.json

# load a specific file in batches with an explicit mutation
gql mload -p test data/person.json -m addEmployees -b 1000

# convert a folder of data to NDF format
gql mload -p test data/ -n ndf/

maddsvc

Add or update a service from source (model file) or manifest (service description).

Note: Either -s (source) or -m (manifest) is required.

Arguments and Options

  • name (required) - name for the service
  • -i | --id (optional) - explicit ID of the service (will overwrite, if it already exists)
  • -d | --desc (optional) - description of the service
  • -s | --source (ootional) - a GraphQL SDL file defining a set of types that Maana will create a fully-managed service for
  • -m | --manifest (optional) - a JSON description of a service manifest instance (see below)

Examples

# create a service from a model with an explicit ID
gql maddsvc MyService -s model.gql -i io.acme.myservice

msignin

Sign into the Maana CLI so you can authenticate against the Maana API.

Compatible with Maana Q v3.1.0+.

Arguments and Options

  • Authentication Token (optional) - the authentication token retrieved from the web UI. You will be asked for this later if it is not provided.
  • -p | --project (optional) - when provided you will only sign in for a specific project instead of all projects in the config file

Examples

# sign into the Maana CLI
gql msignin

maddheaers

Adds authentication headers for authenticating against the Maana API.

Compatible with Maana Q v3.1.0+.

Arguments and Options

  • -p | --project (optional) - only adds the headers to a specific project when provided, otherwise adds them to all the projects in the config file

Examples

# add headers to a project
gql maddheaders -p ckg

menv

Used to export the authentication environment variables into your terminal so that the CLI commands can use them.

Compatible with Maana Q v3.1.0+.

Arguments and Options

  • -s | --shell (optional) - defines the shell that you are using (bash, fish, zsh, cmd, powershell). If this is not provided, the SHELL environment variable is used.
  • -p | --project (optional) - when provided will look for project specific authentication information instead of looking at the root config file level

Examples

# Bash
gql menv --shell bash
rem Windows command line
gql menv --shell cmd
# Windows power shell
gql menv --shell powershell

mrefreshauth

Used to get an new authentication token when it has expired. The Maana API must be configured to support this.

Compatible with Maana Q v3.1.0+.

Arguments and Options

  • -p | --project (optional) - when provided this will refresh project specific authentication information instead of doing it at the root config level

Examples

# refreshing an authentication token
gql mrefreshauth

Add authentication to requests

Maana endpoints require a valid (authenticated) user in order to prevent unauthorized access.

Maana Q v3.1.0 and later

After creating a new .graphqlconfig file connecting to a Maana API endpoint:

  • Login to the Maana Knowledge Portal
  • Click on your user icon and select your profile
  • At the bottom of the profile page click the 'Get CLI Authentication Token' button
  • Go through the login process (again)
  • Copy the generated auth token that shows up below the button
  • In the terminal run gql msignin and when asked paste the Authentication Token into the prompt
  • Then run gql menv --shell <your shell> and follow the directions at the bottom of the output
  • Run gql ping to test out that the authentication works (you will get an error if it did not)

Additional Notes

  • When you add another project to your .graphqlconfig file you can run gql maddheaders --project <Project Name> to add the headers to the new project.
  • When you want to run the CLI against the Maana API in a different terminal window you will need to run gql env again.
  • If your authentication token expires you can run gql mrefreshauth to refresh the authentication token, when the Maana API is configured to allow the refreshing of authentication tokens.

Maana Q v3.0.5

After creating a new project connecting to a Maana endpoint, you will need to setup the project to add an authentication header to the requests.

  • Login to the Maana Knowledge Portal
  • Click on your user icon and select your profile
  • At the bottom of the profile page click the 'Get CLI Authentication Token' button
  • Go through the login process (again)
  • Copy the generated auth token that shows up below the button
  • In the terminal add an environment variable for the auth token
# *nix based systems
export AUTH_TOKEN_ENV=<paste auth token here>
rem Windows command line
set AUTH_TOKEN_ENV=<paste auth token here>
# Windows power shell
$Env:AUTH_TOKEN_ENV = "<paste auth token here>"

Add the authorization header to the Maana endpoint:

     "ckg": {
      "schemaPath": "ckg.graphql",
       "extensions": {
         "endpoints": {
-           "default": "https://qtraining01.knowledge.maana.io:8443/graphql"
+           "default": {
+             "url": "https://qtraining01.knowledge.maana.io:8443/graphql",
+             "headers": {
+               "Authorization": "Bearer ${env:AUTH_TOKEN_ENV}"
+             }
+           }
         }
       }
     }

To build and install

npm i
npm run build
npm i -g

To publish

npm adduser --registry https://registry.npmjs.org
npm publish --registry https://registry.npmjs.org
3.2.14-beta.1

4 years ago

3.2.11

5 years ago

3.2.11-beta.1

5 years ago

3.2.10

5 years ago

3.2.7-beta.62

5 years ago

3.2.9

5 years ago

3.2.8

5 years ago

3.2.8-beta.63

5 years ago

3.2.6-beta.60

5 years ago

3.2.5-beta.59

5 years ago

3.2.4-beta.58

5 years ago

3.2.4-beta.57

5 years ago

3.2.3-beta.54

6 years ago

3.2.3

6 years ago

3.2.4-beta.56

6 years ago

3.2.2

6 years ago

3.2.3-beta.53

6 years ago

3.2.2-beta.50

6 years ago

3.2.2-beta.43

6 years ago

3.2.2-beta.42

6 years ago

3.2.2-beta.41

6 years ago

3.2.2-beta

6 years ago

3.2.1

6 years ago

3.2.2-beta.39

6 years ago

3.2.1-beta.38

6 years ago

3.2.0

6 years ago

3.2.1-beta.37

6 years ago

3.2.0-beta.36

6 years ago

3.2.0-beta.35

6 years ago

3.2.0-beta.34

6 years ago

3.2.0-beta.33

6 years ago

3.2.0-beta.32

6 years ago

3.2.0-beta.31

6 years ago

3.2.0-beta.1

6 years ago

3.2.0-beta.0

6 years ago

3.2.0-beta.30

6 years ago

3.2.0-beta.29

6 years ago

3.2.0-beta.28

6 years ago

3.2.0-beta.27

6 years ago

3.1.6

6 years ago

3.2.0-beta.26

6 years ago

3.1.6-beta.25

6 years ago

3.1.5

6 years ago

3.1.5-beta.24

6 years ago

3.1.5-beta.21

7 years ago

3.1.5-beta.19

7 years ago

3.1.4

7 years ago

3.1.15-beta.18

7 years ago

3.1.4-beta.17

7 years ago

3.1.4-beta.16

7 years ago

3.1.4-beta.15

7 years ago

3.1.4-beta.14

7 years ago

3.1.4-beta.12

7 years ago

3.1.4-beta.11

7 years ago

3.1.4-beta.2

7 years ago

3.1.4-beta.1

7 years ago

3.1.3

7 years ago

3.1.1-beta.10

7 years ago

3.1.1-beta.9

7 years ago

3.1.1-beta.8

7 years ago

3.1.1-beta.6

7 years ago

3.1.1-beta.5

7 years ago

3.1.1-beta.4

7 years ago

3.1.1-beta.3

7 years ago

3.1.1-beta.2

7 years ago

3.1.1-beta.1

7 years ago

3.1.1

7 years ago

3.1.0-release

7 years ago

3.1.0

7 years ago

3.1.0-beta8

7 years ago

3.1.0-beta6

7 years ago

3.1.0-beta5

7 years ago

3.1.0-beta4

7 years ago

3.1.0-beta3

7 years ago

3.1.0-beta2

7 years ago

1.0.36

7 years ago

1.0.35

7 years ago

1.0.34

7 years ago

1.0.33

7 years ago

1.0.32

7 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.29

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago