From a7b9f326e48ba6374aa6effe82d3d2c9e013476c Mon Sep 17 00:00:00 2001 From: Kyrch Date: Fri, 25 Jul 2025 02:23:01 -0300 Subject: [PATCH] docs(graphql): added every relationship available (#113) --- docs/guide/graphql/filtering/index.md | 6 +- docs/guide/graphql/relationships/index.md | 85 ++++++++++++++++++++++- 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/docs/guide/graphql/filtering/index.md b/docs/guide/graphql/filtering/index.md index 63e33f6..dc3126e 100644 --- a/docs/guide/graphql/filtering/index.md +++ b/docs/guide/graphql/filtering/index.md @@ -65,8 +65,10 @@ query { data { name animethemes(type: OP) { - type - sequence + data { + type + sequence + } } } } diff --git a/docs/guide/graphql/relationships/index.md b/docs/guide/graphql/relationships/index.md index 7eb377f..c2b2b31 100644 --- a/docs/guide/graphql/relationships/index.md +++ b/docs/guide/graphql/relationships/index.md @@ -8,9 +8,45 @@ title: Relationships The AnimeThemes API implements relationships for most types, previously known as allowed included in the REST API. -// TODO: Waiting API refactor: pagination everywhere. +The many-to-many, one-to-many and polymorphic one-to-many relationships apply pagination. -## Many-to-Many +## Many-to-One (BelongsTo) + +A many-to-one relationship has a object that references the foreign type. + +```graphql +query { + animethemes { + data { + sequence + anime { + name + } + } + } +} +``` + +## One-to-Many (HasMany) + +An one-to-many relationship has a list of objects that reference the related type. + +```graphql +query { + animes { + data { + name + animethemes(first: 2) { + data { + sequence + } + } + } + } +} +``` + +## Many-to-Many (BelongsToMany) A many-to-many relationship has a `edges` list that contains edge objects. @@ -65,4 +101,49 @@ will return the JSON: } } } +``` + +## Polymorphic Many-to-One (MorphTo) + +An union type indicates that a field might have multiple object types. + +```graphql +query { + performances { + data { + artist { + ... on Artist { + name + } + ... on Membership { + group { + name + } + member { + name + } + } + } + } + } +} +``` + +## Polymorphic One-to-Many (MorphMany) + +The inverse relationship of polymorphic many-to-one. Applies pagination. + +```graphql +query { + memberships { + data { + performances { + data { + alias + as + } + } + } + } +} ``` \ No newline at end of file