Skip to content

Functions:DataAPI

Thomas Timmer edited this page Sep 16, 2024 · 4 revisions

DataAPI

In order to work with application data in functions, the runtime exposes the gql helper, which connects with the DataAPI. All of the queries available in the DataAPI are available with the gql helper. Next to this, we also supported mutations to create, update and delete data.

For more info/details on DataAPI Mutations

Couple of examples:


Read

Example:

constquery=` query { onePost(where: $where) { id title } }`;const{data, errors}=awaitgql(query,{where: {id: {eq: id}}});

Create

Example:

constmutation=` mutation { createPost(input: $input) { id } }`;const{data, errors}=awaitgql(mutation,{input: {title: "New Post"}});

Update

Example:

constmutation=` mutation { updatePost(id: $id, input: $input) { id } }`;const{data, errors}=awaitgql(mutation,{id: id,input: {title: "Updated Post"}});

Delete

Example:

constmutation=` mutation { deletePost(id: $id) { id } }`;const{data, errors}=awaitgql(mutation,{id: id});

Clone this wiki locally