Fetching a Record

Fetch a single record from the API

Fetching specific records is an essential operation, especially when you want details about a particular item or user. With Noloco's dynamic GraphQL API, you can retrieve specific records efficiently using the table's name. This guide will walk you through the process and the structure required to fetch a particular record.

Querying a Specific Record

To fetch a specific record, use the table name in your query. The query is structured as: query <tableName>, where <tableName> represents the table containing the record you wish to retrieve.

For instance:

  • To fetch details about a specific user, the query starts as query user.

Specifying the Unique Identifier

To fetch a specific record, you need to provide a unique identifier. This ensures that the record returned matches your exact criteria. You can use:

  • id: The unique identifier for the record.

  • uuid: A universally unique identifier.

  • Custom unique fields: Tables may have other unique fields specified, such as email on the User table. You can use these as arguments to pinpoint the record.

Example:

query {
  user(email: "example@email.com") {
    id
    firstName
    lastName
    email
  }
}

Selecting Fields to Return

Once you've identified which record you want, you can specify the fields you wish to return. You're not limited to only the fields on the table. If there are relationships set up, such as the lead of a project, you can also retrieve related fields.

Example:

query {
query {
  projects(id: 17) {
    name
    description
    lead {
      id
      firstName
      lastName
      email
    }
  }
}

In the example above, not only are we fetching details about a specific project, but we're also retrieving information about its lead, a related user field.

Conclusion

Noloco's dynamic GraphQL API offers a structured and precise method for fetching specific records. By understanding the query structure, unique identifiers, and how to specify return fields, you can easily retrieve detailed information about any record in your system. This ability enhances data retrieval efficiency and ensures you always have the right data at your fingertips.

Last updated