Sticky F.A.Q.

API Reference > Database

  • 24 November 2023
  • 2 replies
  • 110 views
API Reference > Database
Userlevel 7

Do you need help with your API queries and/or mutation?

Here are a few that might help you!😉

 

🔎Queries

📍 GET TABLE RECORDS WITH PAGINATION - TABLE ID

{
  table_records(first: 10, table_id: "XXXXXXX") {
    edges {
      cursor
      node {
        id
        title
        url
      }
    }
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }
  }
}

📍 GET TABLE RECORDS  -  TABLE RECORD ID
{
  table_record(id: XXX) {
    assignees {
      id
      name
    }
    created_at
    created_by {
      id
      name
    }
    due_date
    finished_at
    id
    labels {
      id
      name
    }
    parent_relations {
      name
      source_type
    }
    record_fields {
      array_value
      date_value
      datetime_value
      filled_at
      float_value
      name
      required
      updated_at
      value
    }
    summary {
      title
      value
    }
    table {
      id
    }
    title
    updated_at
    url
  }
}

📍 FIND TABLE RECORDS  -  FIELD ID | FIELD VALUE
{
  findRecords(tableId:"xxxx", first: 50, search:{fieldId:"xxx", fieldValue:"xxxx"}){
    edges{
      node{
        title
        id
      }
    }
  }
}
 

🛠Mutations

📍CREATE TABLE RECORD

mutation {
  createTableRecord(
    input: {
      table_id: "xxxxx"
      title: "my record"
      due_date: "2017-12-31T00:00-03:00"
      fields_attributes: [
        { field_id: "first_name", field_value: "Tom" },
        { field_id: "last_name", field_value: "Trindade" },
        { field_id: "email", field_value: "tom@trindade.com" }
      ]
    }
  ) {
    table_record {
      id
      title
      due_date
      record_fields {
        name
        value
      }
    }
  }
}


📍CREATE TABLE FIELD

 {
  createTableField(
    input: {
      table_id: "xxx"
      type: "radio_vertical"
      label: "Gender"
      options: ["Female", "Male"]
      description: "Select your gender"
      help: ""
      required: true
      minimal_view: false
      custom_validation: ""
    }
  ) {
    table_field {
      id
      label
      type
      options
      description
      help
      required
      minimal_view
      custom_validation
    }
  }
}
 

📍UPDATE TABLE RECORD
mutation {
  updateTableRecord(
    input: {
      id: "xxxx"
      title: "My custom title"
      due_date: "2017-07-31T00:00-05:00"
    }
  ) {
    table_record {
      id
      title
      due_date
      record_fields {
        name
        value
      }
    }
  }
}

📍SET TABLE RECORD FIELD VALUE

mutation {
  setTableRecordFieldValue(
    input: {
      table_record_id: "xxx"
      field_id: "first_name"
      value: "Theo"
    }
  ) {
    table_record {
      id
      title
    }
    table_record_field {
      value
    }
  }
}

📍DELETE TABLE RECORD

mutation {
  deleteTableRecord(input: {id: "xxxx"}) {
    success
  }
}

📍MUTIPLES CREATE TABLE RECORD

mutation {
  record1: createTableRecord(input: {
    table_id: "xxxx",
    fields_attributes: [
      {field_id: "xxxx", field_value: "xxxx"}
    ]}) {
    table_record {
      id
    }
  }
  n2: createTableRecord(input: {
    table_id: "xxxx",
    fields_attributes: [
      {field_id: "xxxx", field_value: "xxxx"}
    ]}) {
    table_record {
      id
    }
  }
}
 

📍UPDATE STATUS FIELD

First you need to know the status ID
{
  table(id:"xxxx"){
    statuses{
      name
      id
    }
  }
}


After that you can do the action
mutation {
  updateTableRecord(input: {statusId: xxx, id: xxx}) {
    table_record {
      title
      status {
        name
      }
    }
  }
}


 


2 replies

Userlevel 7
Badge +18

Very good!

Userlevel 7
Badge +13

Great! Thanks for sharing

Reply