Link Fields

THIS PAGE
In the graph
In the CMS
In the API

Resource fields are allow you to link to other tables. This allows the field to contain the information thats populated from your other tables. In terms of databases, they are foreign keys.

In the graph

Screenshot

Create a Resource field by creating a new field and marking the input type as Resource. You can then select a table to be linked from the dropdown in the properties panel of the field.

Additional Properties

Property Description
Table The table to link to. Read Recipe
Multiple Selection Whether the field can hold multiple items from the linked table
Required Whether the value is a required field. Can be set in the Validations section

Validations

The resource field only supports validations when multiple selection is on.

Operate On Possible Conditions
Number of Items > , >= ,= ,<= ,< ,

Multiple validations can be chained together with AND operations

See Field Validations for more information on how to add validations.

In the CMS

Screenshot

When you publish a Resource field, it's available in the Content Management System as a dropdown input. The user can select values populated from the table you linked to.

If the multiselect property is enabled for a field, then the user can select multiple options from the dropdown.

Example: If we have a Movie Actors field in a Movies Table linked to the Actors table, then the dropdown in the CMS for Movie Actors would have entries from Actors as it's options (Robert Downey Jr., Chris Pratt etc).

Screenshot

In the API

In the API the output response for this field is an Object that has fields from the linked table.

Sample GraphQL Request

{
  movies {
    title
    movieActors {
      # Linked to the Actor table
      title
      image
    }
  }
}

Sample GraphQL Response

{
  "data": {
    "movies": [
      {
        "title": "Superman vs. Spiderman",
        "movieActors": [
          {
            "title": "Chris Pratt",
            "image": "https://cdn.canonic.dev/user-uploads/di12bd974gyueib3iyrdi223dv/chris-pratt-md2i3.png"
          }
        ]
      }
    ]
  }
}