Using fauna-shell to upload graphql schema for CI/CD

I’m trying to use fauna-shell to upload schema.graphql:

fauna upload-graphql-schema fauna/schema.graphql --domain db.us.fauna.com --secret SECRET_HERE --mode override

But I keep getting:

UPLOADING SCHEMA (mode=override): fauna/schema.graphql
    TypeError: Only HTTP(S) protocols are supported

EDIT:

Using the command

fauna upload-graphql-schema fauna/schema.graphql --endpoint https://graphql.us.fauna.com/import --secret SECRET_HERE --mode override

I get the following error:

Error: Could not Connect to undefined Unauthorized Secret

EDIT:

Using the command:

fauna upload-graphql-schema fauna/schema.graphql --domain graphql.us.fauna.com --secret asdasd --mode override

I get:

SyntaxError: Unexpected token I in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.parseJSON (/Users/aprilmintacpineda/.config/yarn/global/node_modules/faunadb/src/_json.js:16:15)
    at /Users/aprilmintacpineda/.config/yarn/global/node_modules/faunadb/src/Client.js:318:33
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async UploadGraphQLSchemaCommand.getClient (/Users/aprilmintacpineda/.config/yarn/global/node_modules/fauna-shell/src/lib/fauna-command.js:104:7)
    at async UploadGraphQLSchemaCommand.run (/Users/aprilmintacpineda/.config/yarn/global/node_modules/fauna-shell/src/commands/upload-graphql-schema.js:24:11)
    at async UploadGraphQLSchemaCommand._run (/Users/aprilmintacpineda/.config/yarn/global/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/Users/aprilmintacpineda/.config/yarn/global/node_modules/@oclif/config/lib/config.js:173:24)
    at async Main.run (/Users/aprilmintacpineda/.config/yarn/global/node_modules/@oclif/command/lib/main.js:27:9)
    at async Main._run (/Users/aprilmintacpineda/.config/yarn/global/node_modules/@oclif/command/lib/command.js:43:20)
    SyntaxError: Unexpected token I in JSON at position 0

I have traced it here: faunadb-js/Client.js at v5 · fauna/faunadb-js · GitHub

If I console log the response you will get:

{
  body: 'Invalid endpoint or method.',
  headers: {
    'access-control-allow-credentials': 'true',
    'access-control-allow-headers': 'DNT,Keep-Alive,User-Agent,If-Modified-Since,Cache-Control,Content-Type,Authorization,X-Requested-With,X-Apollo-Tracing,X-Schema-Preview,X-Runtime-Cache-Enabled,X-Query-Timeout',
    'access-control-allow-methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS',
    'access-control-allow-origin': '*',
    'access-control-max-age': '600',
    'alt-svc': 'clear',
    'content-length': '27',
    'content-type': 'plain/text',
    date: 'Fri, 24 Dec 2021 05:38:22 GMT',
    via: '1.1 google'
  },
  status: 400
}

If I console log the options:

{ path: '', query: null, method: 'POST', body: '{"now":null}' }

I finally got it to work by running:

fauna upload-graphql-schema fauna/schema.graphql \
  --domain db.us.fauna.com \
  --secret asdasd \
  --mode override \
  --graphqlHost graphql.us.fauna.com \
  --scheme https \
  --graphqlPort 443

notice how I had to provide all options which were supposed to be optional – which I think is a bug.

PS: DON’T USE --method override!! IT WILL CLEAR ALL RECORDS IN ALL YOUR COLLECTIONS, IT’S ESSENTIALLY THE SAME AS STARTING FROM SCRATCH.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

To clarify, the configurations are optional because they have default values. You need to provide values other than the defaults to connect to different region groups or to localhost (e.g. when running Fauna Dev). The defaults are listed in the docs: upload-graphql-schema | Fauna Documentation

The reason you need to provide both domain and graphqlHost is that the shell also connects to the database directly.

image

1 Like