Looking for the Prisma documentation? You can find it here

Data Export

Last updated a day ago Edit this page

Exporting data can be done either using the CLI or the raw export API. In both cases, the downloaded data is formatted in JSON and adheres to the Normalized Data Format (NDF). As the exported data is in NDF, it can directly be imported into a service with an identical schema. This can be useful when test data is needed for a service, e.g. in a dev environment.

#Data export with the CLI

The Graphcool CLI offers the graphcool export command. It accepts two options:

  • --export-path (short: -e): A file path to a .zip-directory which will be created by the CLI and where the exported data is stored
  • --target (short: -t): The name of the deployment target from which the data should be exported

Under the hood, the CLI uses the expport API that's described in the next section. However, using the CLI provides some major benefits:

  • leveraging the CLI's authentication mechanism (i.e. you don't need to manually send your authentication token)
  • writing downloaded data directly to file system
  • cursor management in case multiple requests are needed to export all application data (when doing this manually you need to send multiple requests and adjust the cursor upon each)

#Output format

The data is exported in NDF and will be placed in three directories that are named after the different NDF types: nodes, lists and relations.

#Data export using the raw export API

The raw export API is exposed under the /export path of your service's HTTP endpoint. For example:

  • http://localhost:60000/simple/v1/cjapb3w1d08jc0167wy2c7u2c/export
  • https://api.graph.cool/simple/v1/cjapb3w1d08jc0167wy2c7u2c/export

One request can download JSON data (in NDF) of at most 10 MB in size. Note that you need to provide your authentication token in the HTTP Authorization header of the request!

The endpoint expects a POST request where the body contains JSON with the following contents:

  "fileType": "nodes",
  "cursor": {
    "table": 0,
    "row": 0,
    "field": 0,
    "array": 0

The values in cursor describe the offsets in the database from where on data should be exported. Note that each response for an export request will return a new cursor with either of two states:

  • Terminated (not full): If all the values for table, row, field and array are returned as -1 it means the export has completed.
  • Non-terminated (_full): If any of the values for table, row, field or array is different from -1, it means the maximum size of 10 MB for this response has been reached. If this happens, you can use the returned cursor values as the input for your next export request.


Here is an example curl command for uploading some JSON data (of NDF type nodes):

curl 'http://localhost:60000/simple/v1/cjapb3w1d08jc0167wy2c7u2c/export' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE1MTM1OTQzMTEsImV4cCI6MTU0NTEzMDMxMSwiYXVkIjasd3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIkdpdmVuTmFtZSI6IkpvaG5ueSIsIlN1cm5hbWUiOiJSb2NrZXQiLCJFbWFpbCI6Impyb2NrZXRAZXhhbXBsZS5jb20iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.L7DwH7vIfTSmuwfxBI82D64DlgoLBLXOwR5iMjZ_7nI' \
-d '{"fileType":"nodes","cursor":{"table":0,"row":0,"field":0,"array":0}}' \

The generic version for curl (using placeholders) would look as follows:

curl '__SERVICE_ENDPOINT__/export' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer __JWT_AUTH_TOKEN__' \
-d '{"fileType":"__NDF_TYPE__","cursor": {"table":__TABLE__,"row":__ROW__,"field":__FIELD__,"array":__ARRAY__}} }' \

Was this page helpful?