diff --git a/docs/guide/graphql/relationships/index.md b/docs/guide/graphql/relationships/index.md index 0f72cf8..7eb377f 100644 --- a/docs/guide/graphql/relationships/index.md +++ b/docs/guide/graphql/relationships/index.md @@ -6,8 +6,63 @@ title: Relationships --- -// TODO +The AnimeThemes API implements relationships for most types, previously known as allowed included in the REST API. + +// TODO: Waiting API refactor: pagination everywhere. ## Many-to-Many -// TODO \ No newline at end of file +A many-to-many relationship has a `edges` list that contains edge objects. + +The edge object contains the pivot fields of the relationship and a `node` object that references the related type. + +Both fields `createdAt` and `updatedAt` are available for every many-to-many relationship. + +The following query +```graphql +query { + animes { + data { + name + resources { + edges { + node { + link + } + as + createdAt + updatedAt + } + } + } + } +} +``` +will return the JSON: +```json +{ + "data": { + "animes": { + "data": [ + { + "name": ".hack//Liminality", + "resources": { + "edges": [ + { + "node": { + "link": "https://myanimelist.net/anime/299" + }, + "as": null, + "createdAt": "2021-03-27T00:46:24+00:00", + "updatedAt": "2021-03-27T00:46:24+00:00" + } + ... + ] + } + } + ... + ] + } + } +} +``` \ No newline at end of file