3.2.11 • Published 3 years ago

graphql-cli-maana v3.2.11

Weekly downloads
1
License
MIT
Repository
github
Last release
3 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

3 years ago

3.2.11

4 years ago

3.2.11-beta.1

4 years ago

3.2.10

4 years ago

3.2.7-beta.62

4 years ago

3.2.9

4 years ago

3.2.8

4 years ago

3.2.8-beta.63

4 years ago

3.2.6-beta.60

4 years ago

3.2.5-beta.59

4 years ago

3.2.4-beta.58

4 years ago

3.2.4-beta.57

4 years ago

3.2.3-beta.54

4 years ago

3.2.3

4 years ago

3.2.4-beta.56

4 years ago

3.2.2

4 years ago

3.2.3-beta.53

4 years ago

3.2.2-beta.50

4 years ago

3.2.2-beta.43

4 years ago

3.2.2-beta.42

4 years ago

3.2.2-beta.41

4 years ago

3.2.2-beta

4 years ago

3.2.1

4 years ago

3.2.2-beta.39

4 years ago

3.2.1-beta.38

5 years ago

3.2.0

5 years ago

3.2.1-beta.37

5 years ago

3.2.0-beta.36

5 years ago

3.2.0-beta.35

5 years ago

3.2.0-beta.34

5 years ago

3.2.0-beta.33

5 years ago

3.2.0-beta.32

5 years ago

3.2.0-beta.31

5 years ago

3.2.0-beta.1

5 years ago

3.2.0-beta.0

5 years ago

3.2.0-beta.30

5 years ago

3.2.0-beta.29

5 years ago

3.2.0-beta.28

5 years ago

3.2.0-beta.27

5 years ago

3.1.6

5 years ago

3.2.0-beta.26

5 years ago

3.1.6-beta.25

5 years ago

3.1.5

5 years ago

3.1.5-beta.24

5 years ago

3.1.5-beta.21

5 years ago

3.1.5-beta.19

6 years ago

3.1.4

6 years ago

3.1.15-beta.18

6 years ago

3.1.4-beta.17

6 years ago

3.1.4-beta.16

6 years ago

3.1.4-beta.15

6 years ago

3.1.4-beta.14

6 years ago

3.1.4-beta.12

6 years ago

3.1.4-beta.11

6 years ago

3.1.4-beta.2

6 years ago

3.1.4-beta.1

6 years ago

3.1.3

6 years ago

3.1.1-beta.10

6 years ago

3.1.1-beta.9

6 years ago

3.1.1-beta.8

6 years ago

3.1.1-beta.6

6 years ago

3.1.1-beta.5

6 years ago

3.1.1-beta.4

6 years ago

3.1.1-beta.3

6 years ago

3.1.1-beta.2

6 years ago

3.1.1-beta.1

6 years ago

3.1.1

6 years ago

3.1.0-release

6 years ago

3.1.0

6 years ago

3.1.0-beta8

6 years ago

3.1.0-beta6

6 years ago

3.1.0-beta5

6 years ago

3.1.0-beta4

6 years ago

3.1.0-beta3

6 years ago

3.1.0-beta2

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago