Skip to main content
Version: v2.x

Actions Relationships


Actions are a way to extend your GraphQL schema with custom queries or mutations. It is quite a typical case that an action's response is actually related to existing objects in the schema and the action needs to be connected with the rest of the graph.

For example, a custom insertAuthor action will be related to the author object in the schema. Hence, we would want to be able to get information about the author from the graph as a response of the insertAuthor mutation.

Using action output type's relationships

Actions can be connected to the rest of the graph by setting up relationships on its return output type.

This allows complex responses to be returned as an action's response traversing the graph via the output type's relationships.

For example, given the action:

type Mutation {
updateAuthor(id: Int!, name: String!): UpdateAuthorOutput

type UpdateAuthorOutput {
author_id: Int!

We can create an object relationship called updatedAuthor between the UpdateAuthorOutput object type and the author table using the UpdateAuthorOutput.author_id and fields.

The object type will now be modified as:

type UpdateAuthorOutput {
author_id: Int!
updatedAuthor: author

Now we can make a mutation request with a complex response such as:

mutation updateAuthorAndGetArticles($id: Int, $name: String) {
updateAuthor(id: $id, name: $name) {
updatedAuthor {
articles {

See more details at custom object type relationships

Creating relationships for custom object types

You can create relationships for custom output types by:

Head to the Actions -> [action-name] -> Relationships tab in the Console for the Action returning the output type.

Set the output type relationship as shown below:

Console action relationship

Hit Save to create the relationship.

Additional Resources

Introduction to Hasura Actions - View Recording.