---
title: entities.customEntityRelation
description: Read custom entity relation records with the customEntityRelation repository.
canonical: https://developers.coevera.com/reference/graphql/custom-entity-relation/
section: graphql
verification: schema
generatedFrom: schema f155746 (2026-10-20)
publisher: Coevera
---

# entities.customEntityRelation

Read custom entity relation records with the customEntityRelation repository.

## Queries

- `getById(entityId: ID!): CustomEntityRelationEntity` Returns the record with the given id, or null when there is none. Deleted records are returned as well.
- `getByIds(entityIds: [ID!]!): [CustomEntityRelationEntity!]!` Returns the records with the given ids; ids without a record are left out. Deleted records are returned as well.
- `getAll(limit: Int, offset: Int, filter: CustomEntityRelationFilterInput, orderBy: [CustomEntityRelationOrderByInput!], includeDeleted: Boolean): [CustomEntityRelationEntity!]!` Returns the records that match the filter, paged with limit and offset.
- `getByCriteria(filter: CustomEntityRelationFilterInput, orderBy: [CustomEntityRelationOrderByInput!], includeDeleted: Boolean, before: String, after: String, first: Int, last: Int): CustomEntityRelationEntityConnection` Returns the records that match the filter as a cursor-paginated connection.
- `getPublished(limit: Int, offset: Int, filter: CustomEntityRelationFilterInput, orderBy: [CustomEntityRelationOrderByInput!], includeDeleted: Boolean): [CustomEntityRelationEntity!]!` Returns the published records that match the filter, paged with limit and offset.
- `getDrafts(filter: CustomEntityRelationFilterInput, orderBy: [CustomEntityRelationOrderByInput!]): [CustomEntityRelationEntity!]!` Returns the records that match the filter, with pending unpublished changes applied where a draft exists.
- `getDraftById(entityId: ID!): CustomEntityRelationEntity!` Returns the record with the given id, with its pending unpublished changes applied when a draft exists.

## Types

### CustomEntityRelationEntity (object)

Custom relation that links records of two entities through a pair of relation fields, one on each side.

- `isDeleteProtected: Boolean!` True when the record is protected against deletion because it must always exist in the space. Deleting a record that is not protected can still fail on other checks. Read-only.
- `hasDraft: Boolean` True when the record has unpublished draft changes, including pending translation changes, that can be published.
- `id: ID!` Unique identifier of entity.
- `isDeleted: Boolean` Specifies if the entity is considered deleted.
- `modified: DateTime` Last modification time.
- `created: DateTime` Creation time.
- `field1: FieldEntity` Lookup field on the first side of the custom relation: the lookup field the relation was created from.
- `field2: FieldEntity` Lookup field on the second side of the custom relation, created automatically on the linked entity.
- `entityFilter1: JSONString` Condition limiting which records of the field_1 entity can be selected in field_2, as a JSON object conforming to the `FieldFilter` type; empty for no restriction.
- `entityFilter2: JSONString` Condition limiting which records of the field_2 entity can be selected in field_1, as a JSON object conforming to the `FieldFilter` type; empty for no restriction.
- `field1Id: ID!` Id of the lookup field on the first side of the custom relation.
- `field2Id: ID!` Id of the lookup field on the second side of the custom relation.
- `hasIsPrimary: Boolean` When true, one of the records linked through the relation can be marked as primary. Cannot be switched back to false once enabled.
- `showRelated1: Boolean` When true, field2 offers only records related to the record being edited. Not supported yet; must be false.
- `showRelated2: Boolean` When true, field1 offers only records related to the record being edited (e.g. the contacts of its account).
- `showTab1: Boolean!` When true, the records linked through field1 are shown in a tab named tabName1.
- `showTab2: Boolean!` When true, the records linked through field2 are shown in a tab named tabName2.
- `tabName1: String!` Name of the tab that shows the records linked through field1.
- `tabName2: String!` Name of the tab that shows the records linked through field2.
- `isPublished: Boolean` True when the entity configuration is published; false while it exists only as an unpublished draft.
- `revision: Int` Revision when entity was lastly changed.
- `instancePermissions: [EntityPermsEnum!]! (1 args)` Permissions the current user has on this record, out of the requested ones.

### CustomEntityRelationEntityConnection (object)

Paginated list of CustomEntityRelation records.

- `pageInfo: PageInfo!` Pagination data for this connection.
- `edges: [CustomEntityRelationEntityEdge]!` Contains the nodes in this connection.
- `totalCount: Int` Total number of items in the connection.

### CustomEntityRelationEntityEdge (object)

A Relay edge containing a `CustomEntityRelationEntity` and its cursor.

- `node: CustomEntityRelationEntity` The item at the end of the edge
- `cursor: String!` A cursor for use in pagination

### CustomEntityRelationFilterInput (input)

Filter conditions for CustomEntityRelation records. Conditions on different fields are combined with AND; use OR, AND and NOT for other combinations.

- `OR: [CustomEntityRelationFilterInput!]` Matches records that meet at least one of the listed filters.
- `AND: [CustomEntityRelationFilterInput!]` Matches records that meet all of the listed filters.
- `NOT: CustomEntityRelationFilterInput` Matches records that do not meet this filter.
- `globalSearchQuery: String` Search term matched against the fields that the global search covers for this entity.
- `id: EntityFilterStringField` Unique identifier of entity.
- `isDeleted: Boolean` Specifies if the entity is considered deleted.
- `modified: EntityFilterDateTimeField` Last modification time.
- `created: EntityFilterDateTimeField` Creation time.
- `field1Id: EntityFilterStringField` Id of the lookup field on the first side of the custom relation.
- `field2Id: EntityFilterStringField` Id of the lookup field on the second side of the custom relation.
- `hasIsPrimary: Boolean` When true, one of the records linked through the relation can be marked as primary. Cannot be switched back to false once enabled.
- `showRelated1: Boolean` When true, field2 offers only records related to the record being edited. Not supported yet; must be false.
- `showRelated2: Boolean` When true, field1 offers only records related to the record being edited (e.g. the contacts of its account).
- `showTab1: Boolean` When true, the records linked through field1 are shown in a tab named tabName1.
- `showTab2: Boolean` When true, the records linked through field2 are shown in a tab named tabName2.
- `tabName1: EntityFilterStringField` Name of the tab that shows the records linked through field1.
- `tabName2: EntityFilterStringField` Name of the tab that shows the records linked through field2.
- `isPublished: Boolean` True when the entity configuration is published; false while it exists only as an unpublished draft.
- `revision: EntityFilterNumberField` Revision when entity was lastly changed.
- `field1: FieldFilterInput` Lookup field on the first side of the custom relation: the lookup field the relation was created from. Matches records where a related record meets these conditions.
- `field2: FieldFilterInput` Lookup field on the second side of the custom relation, created automatically on the linked entity. Matches records where a related record meets these conditions.

### CustomEntityRelationOrderByInput (input)

Sorting of CustomEntityRelation records. Set exactly one field in each item; list several items to sort by more fields, in order of priority.

- `id: OrderByEnum` Unique identifier of entity.
- `isDeleted: OrderByEnum` Specifies if the entity is considered deleted.
- `modified: OrderByEnum` Last modification time.
- `created: OrderByEnum` Creation time.
- `field1: [FieldOrderByNestedInput!]` Lookup field on the first side of the custom relation: the lookup field the relation was created from. Sorts by fields of the related record, listed in order of priority.
- `field2: [FieldOrderByNestedInput!]` Lookup field on the second side of the custom relation, created automatically on the linked entity. Sorts by fields of the related record, listed in order of priority.
- `field1Id: OrderByEnum` Id of the lookup field on the first side of the custom relation.
- `field2Id: OrderByEnum` Id of the lookup field on the second side of the custom relation.
- `hasIsPrimary: OrderByEnum` When true, one of the records linked through the relation can be marked as primary. Cannot be switched back to false once enabled.
- `showRelated1: OrderByEnum` When true, field2 offers only records related to the record being edited. Not supported yet; must be false.
- `showRelated2: OrderByEnum` When true, field1 offers only records related to the record being edited (e.g. the contacts of its account).
- `showTab1: OrderByEnum` When true, the records linked through field1 are shown in a tab named tabName1.
- `showTab2: OrderByEnum` When true, the records linked through field2 are shown in a tab named tabName2.
- `tabName1: OrderByEnum` Name of the tab that shows the records linked through field1.
- `tabName2: OrderByEnum` Name of the tab that shows the records linked through field2.
- `isPublished: OrderByEnum` True when the entity configuration is published; false while it exists only as an unpublished draft.
- `revision: OrderByEnum` Revision when entity was lastly changed.

Types several repositories share, such as `PageInfo` and the filter fields, are in the [types index](https://developers.coevera.com/reference/graphql/types.md). The [SDL](https://developers.coevera.com/graphql/schema.graphql) has the whole schema in one file.

## Example

```graphql
query FirstCustomEntityRelations {
  entities {
    customEntityRelation {
      getByCriteria(first: 3, orderBy: [{ modified: Desc }]) {
        totalCount
        edges { node { id modified } }
      }
    }
  }
}
```

```bash
curl 'https://{region}.api.coevera.com/api/v100/app/space/{space_id}/graphql/public' \
  --user "$COEVERA_API_KEY:$COEVERA_API_SECRET" \
  --header 'Content-Type: application/json' \
  --data '{"query":"query FirstCustomEntityRelations { entities { customEntityRelation { getByCriteria(first: 3, orderBy: [{ modified: Desc }]) { totalCount edges { node { id modified } } } } } }"}'
```
