Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Relations → Get

AI-generated

Overview

The Directus (DrWade) node for n8n, when configured with the Resource Relations and Operation Get, retrieves detailed information about a specific relation between collections in a Directus project. This is useful for understanding how two collections are linked via relational fields, which is essential for data modeling, automation, or integration tasks that depend on relationships between tables.

Common scenarios:

  • Inspecting the configuration of a relation to understand its type (e.g., one-to-many, many-to-many).
  • Automating documentation or validation of your Directus schema.
  • Building dynamic workflows that adapt based on the structure of relations in your database.

Practical example:
Suppose you have a books collection with an author field relating to an authors collection. Using this node, you can fetch all metadata about the author relation, such as the type of relationship, involved collections, and configuration details.


Properties

Name Type Meaning
Collection options Unique name of the parent collection. Selects which collection's relation to inspect.
Field options Name of the field holding the related primary key. Specifies which relation to retrieve info for.

Output

The output will be a single object in the json field containing the full metadata of the specified relation. The structure typically includes:

{
  "collection": "books",
  "field": "author",
  "related_collection": "authors",
  "meta": {
    // Various metadata about the relation, such as type, junction table, etc.
  },
  // Additional properties describing the relation
}
  • The exact keys and nested structure depend on your Directus instance and the specific relation.
  • No binary data is produced by this operation.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

Common issues:

  • Invalid Collection or Field: If the provided collection or field does not exist, the node will throw an error. Double-check spelling and existence in Directus.
  • Permissions: Insufficient API permissions may result in authorization errors. Ensure the API user has permission to read schema/relations.
  • Network/API Errors: Connectivity issues or incorrect API URLs can cause failures.

Error messages and resolutions:

  • "Cannot find relation": Verify both the collection and field names are correct and that the relation exists in Directus.
  • "401 Unauthorized" or "403 Forbidden": Check your API credentials and user permissions.
  • "Unexpected token" (JSON parse error): This could indicate a misconfiguration or unexpected response from the API; check your Directus server logs.

Links and References


Discussion