upload-graphql-schema

Upload and import a GraphQL schema file to the GraphQL API.

Syntax

fauna upload-graphql-schema GRAPHQL_FILE_PATH

Description

The upload-graphql-schema command uploads and imports the given GraphQL schema file to the GraphQL API.

Use the optional --mode parameter to set the schema import mode.

If you don’t pass any options at the command line, Fauna uses the options in the fauna-shell configuration file.

Arguments

Argument Description

GRAPHQL_FILE_PATH

The path to the GraphQL schema file that you want to upload to the GraphQL API. The file name must have the .gql or .graphql extension.

Options

Option Description

--domain=<domain>

Optional Fauna server domain, that is, the hostname where Fauna is running. Defaults to db.fauna.com.

--endpoint=<name>

Optional name of the endpoint to use for the command.

--port=<number>

Optional connection port. Defaults to 8443.

--scheme=<scheme>

Optional connection scheme. Must be one of https or http. Defaults to https.

--secret=<secret>

Optional secret to use. A secret authenticates your connection to Fauna, and connects you to a database.

--timeout=<integer>

Optional connection timeout, an integer number of milliseconds. When the interval has elapsed, fauna-shell stops waiting for a response and displays an error.

The default is zero, which means that fauna-shell waits until a response is received.

--graphqlHost=<GraphQLAPI host name>

The hostname of the GraphQL API to connect to.

--graphqlPort=<GraphQLAPI host port>

The port of the GraphQL API to connect to.

--mode=<import_mode>

The schema import mode to use. Must be one of:

- merge: combines the new schema with the existing schema.

- replace: replaces the existing schema with the new schema.

- override: replaces the existing schema with the new schema AND deletes all of the associated documents and indexes. Data loss occurs with override mode.

The default mode is merge.

Examples

The following example imports a schema file in the current directory:

$ fauna upload-graphql-schema ./schema.gql
UPLOADING SCHEMA (mode=merge): ./schema.gql
RESPONSE:
Schema imported successfully.
Use the following HTTP header to connect to the FaunaDB GraphQL API:
{ "Authorization": "Bearer fnAEMRODcCACANIiSnji7-BEalUcbAufrmGrgN8m" }

The following example imports the same schema file as the previous example, this time using the replace schema import mode:

$ fauna upload-graphql-schema ./schema.gql --mode=replace
UPLOADING SCHEMA (mode=replace): ./schema.gql
RESPONSE:
Schema imported successfully.
Use the following HTTP header to connect to the FaunaDB GraphQL API:
{ "Authorization": "Bearer fnAEMRODcCACANIiSnji7-BEalUcbAufrmGrgN8m" }

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!