This is actually a known limitation with using GraphQL with the docker container: you cannot use "secret"
as a secret for GraphQL. We have a task to document this behavior.
Workaround
You need to create a key for the new database and supply that key
> fauna create-database MY_DATA --endpoint localhost
creating database MY_DATA
created database MY_DATA
To start a shell with your new database, run:
fauna shell MY_DATA
Or, to create an application key for your database, run:
fauna create-key MY_DATA
> fauna create-key MY_DATA admin --endpoint localhost
creating key for database 'MY_DATA' with role 'admin'
created key for database 'MY_DATA' with role 'admin'.
secret: fnAE8YNco_ACAEAO9yWrY_DtOpdWoZZnUfPXmxDR
To access 'MY_DATA' with this key, create a client using
the driver library for your language of choice using
the above secret.
> fauna upload-graphql-schema ./schema.gql --mode override --secret fnAE8YNco_ACAEAO9yWrY_DtOpdWoZZnUfPXmxDR --graphqlHost localhost --graphqlPort 8084 --scheme http --timeout 5 --domain localhost --port 8443
UPLOADING SCHEMA (mode=override): ./schema.gql
RESPONSE:
Schema imported successfully.
Use the following HTTP header to connect to the FaunaDB GraphQL API:
{ "Authorization": "Bearer fnAE8YNco_ACAEAO9yWrY_DtOpdWoZZnUfPXmxDR" }
The format for the create-database
is meant to be human readable, not for machines. You can get the JSON response by running eval
instead
> fauna eval --endpoint localhost MY_DATA 'CreateKey({ role: "admin" })'
{"ref":{"@ref":{"id":"356211021705118208","collection":{"@ref":{"id":"keys"}}}},"ts":1675968152640000,"role":"admin","secret":"fnAE8YQJddACAJD9uN40Q92ki45NBIa9f4ZKuErT","hashed_secret":"$2a$05$XDVSHQD6lAAK/vHitHy5nOL7WdHMDXeYN9PFN0NF5uFcvsjbH7OA6"}
or
> fauna eval --endpoint localhost MY_DATA 'CreateKey({ role: "admin" })' | jq '.secret' -r
fnAE8YRD92ACANvK9Yx5xhnyQfn21Ir7KcGiM47a