mirror of
https://github.com/AnimeThemes/animethemes-api-docs.git
synced 2026-07-11 01:34:06 +02:00
docs(graphql): added every relationship available (#113)
(cherry picked from commit a7b9f326e4)
This commit is contained in:
@@ -65,8 +65,10 @@ query {
|
||||
data {
|
||||
name
|
||||
animethemes(type: OP) {
|
||||
type
|
||||
sequence
|
||||
data {
|
||||
type
|
||||
sequence
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -66,3 +102,48 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user