Using Slash GraphQL CLI in Deployment without Login

I have an application with the following structure:

  • One dev slash-graphql backend
  • One prod slash-graphql backend
  • A GitHub actions workflow to deploy the application on merges to main that does the following:
  1. Updates lambdas in prod backend based on lambdas.ts file in repo
  2. Update schema in prod backend based on schema.graphql file in repo
  3. Launch react app

Everything works here except for the update-lambda step which requires a slash-graphql login call, but I can’t login through my browser in a CI workflow. I feel like just passing an admin token as an argument to the update-lambda call should allow me to update the lambdas similar to how the update-schema command does but it still asks me to login even if I pass the token. Am I missing something here?

You can indeed pass in a token! The -t flag in any subcommand allows you to pass in your token, e.g.

$ slash-graphql update-lambda --help

  $ slash-graphql update-lambda

  -e, --endpoint=endpoint  Slash GraphQL Endpoint
  -f, --file=file          (required) Lambda script file path.
  -q, --quiet              Quiet Output
  -t, --token=token        Slash GraphQL Backend API Tokens

You can create tokens in the settings in the SlashGraphql side bar. Click on API keys, then generate a key for Admin

Annoyingly I had to trawl through the source code to figure this out for myself when I was working on a personal project involving Slash GraphQL. @docs could we get this documented?

Thanks for the reply, I’ve tried that, and when I run:

slash-graphql update-lambda -e $REACT_APP_GRAPHQL_ENDPOINT -f=lambdas.ts -t $DGRAPH_ADMIN_KEY

I get the response:

Error: Please login with slash-graphql login in order to access endpoints by url

It also occurs when I pass the endpoint by backend ID, though I get this response instead:

Error: Please login with slash-graphql login

I am using slash-graphql/1.17.0 darwin-x64 node-v15.4.0.

Is this a bug or am I doing something wrong?

I get the same. When I login using a different account from the backend I’m trying to update, I get:

Error: Cannot find backend <backend-url>

Hey @chewxy - any chance you saw my note about the command still failing when passing the token? I can’t get it to work and it feels like this is a bug

It would appear to be a bug. It may be related to when we changed auth systems. Will let you know

Any news here? I still can’t use the CLI for my CI/CD and have to update manually. Or please advise if there are workarounds.

1 Like

@chewxy I’m having the same issue. Is there any update? It’s been 4 months.

The slash-graphql CLI has been replaced by cerebro.

Some of the functions that were part of the CLI are available on the admin endpoint as well such as schema updating

1 Like