From 3965f137e14b9fa8792fba60b357f7003dd14ca0 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 4 Aug 2020 14:25:18 -0400 Subject: [PATCH] Move GraphQL queries up a level --- .../API/Anilist/{GraphQL => }/.graphqlconfig | 0 src/AnimeClient/API/Anilist/AnilistTrait.php | 6 +- .../CreateFullMediaListEntry.graphql | 0 .../Mutations/CreateMediaListEntry.graphql | 0 .../Mutations/DeleteMediaListEntry.graphql | 0 .../Mutations/IncrementMediaListEntry.graphql | 0 .../Mutations/UpdateMediaListEntry.graphql | 0 .../{GraphQL => }/Queries/CheckLogin.graphql | 0 .../Queries/ListItemIdByMediaId.graphql | 0 .../Queries/MediaIdByMalId.graphql | 0 .../Queries/MediaListItem.graphql | 0 .../Queries/SyncUserList.graphql | 0 .../Queries/Unused/AnimeDetails.graphql | 0 .../Queries/Unused/ListItemIdByMalId.graphql | 0 .../Queries/Unused/MangaDetails.graphql | 0 .../Queries/Unused/MangaIdByMalId.graphql | 0 .../Queries/Unused/UserAnimeList.graphql | 0 .../Queries/Unused/UserMangaList.graphql | 0 .../API/Anilist/{GraphQL => }/schema.graphql | 0 src/AnimeClient/API/Kitsu/.graphqlconfig | 15 ++++ .../API/Kitsu/GraphQL/.graphqlconfig | 22 ------ .../API/Kitsu/KitsuRequestBuilder.php | 6 +- .../Mutations/IncrementLibraryItem.graphql | 0 .../Mutations/UpdateLibraryItem.graphql | 0 .../API/Kitsu/{GraphQL => }/Queries/.gitkeep | 0 .../Queries/AnimeDetails.graphql | 14 ---- .../Queries/AnimeDetailsById.graphql | 0 .../Queries/CharacterDetails.graphql | 4 ++ .../Queries/MangaDetails.graphql | 0 .../Queries/MangaDetailsById.graphql | 0 .../API/Kitsu/Queries/PersonDetails.graphql | 69 +++++++++++++++++++ .../{GraphQL => }/Queries/UserDetails.graphql | 0 .../API/Kitsu/{GraphQL => }/schema.graphql | 0 33 files changed, 92 insertions(+), 44 deletions(-) rename src/AnimeClient/API/Anilist/{GraphQL => }/.graphqlconfig (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Mutations/CreateFullMediaListEntry.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Mutations/CreateMediaListEntry.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Mutations/DeleteMediaListEntry.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Mutations/IncrementMediaListEntry.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Mutations/UpdateMediaListEntry.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/CheckLogin.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/ListItemIdByMediaId.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/MediaIdByMalId.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/MediaListItem.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/SyncUserList.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/Unused/AnimeDetails.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/Unused/ListItemIdByMalId.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/Unused/MangaDetails.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/Unused/MangaIdByMalId.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/Unused/UserAnimeList.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/Queries/Unused/UserMangaList.graphql (100%) rename src/AnimeClient/API/Anilist/{GraphQL => }/schema.graphql (100%) create mode 100644 src/AnimeClient/API/Kitsu/.graphqlconfig delete mode 100644 src/AnimeClient/API/Kitsu/GraphQL/.graphqlconfig rename src/AnimeClient/API/Kitsu/{GraphQL => }/Mutations/IncrementLibraryItem.graphql (100%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Mutations/UpdateLibraryItem.graphql (100%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/.gitkeep (100%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/AnimeDetails.graphql (90%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/AnimeDetailsById.graphql (100%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/CharacterDetails.graphql (87%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/MangaDetails.graphql (100%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/MangaDetailsById.graphql (100%) create mode 100644 src/AnimeClient/API/Kitsu/Queries/PersonDetails.graphql rename src/AnimeClient/API/Kitsu/{GraphQL => }/Queries/UserDetails.graphql (100%) rename src/AnimeClient/API/Kitsu/{GraphQL => }/schema.graphql (100%) diff --git a/src/AnimeClient/API/Anilist/GraphQL/.graphqlconfig b/src/AnimeClient/API/Anilist/.graphqlconfig similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/.graphqlconfig rename to src/AnimeClient/API/Anilist/.graphqlconfig diff --git a/src/AnimeClient/API/Anilist/AnilistTrait.php b/src/AnimeClient/API/Anilist/AnilistTrait.php index 657377e1..bb973970 100644 --- a/src/AnimeClient/API/Anilist/AnilistTrait.php +++ b/src/AnimeClient/API/Anilist/AnilistTrait.php @@ -123,13 +123,12 @@ trait AnilistTrait { */ public function runQuery(string $name, array $variables = []): array { - $file = realpath(__DIR__ . "/GraphQL/Queries/{$name}.graphql"); + $file = realpath(__DIR__ . "/Queries/{$name}.graphql"); if ( ! file_exists($file)) { throw new LogicException('GraphQL query file does not exist.'); } - // $query = str_replace(["\t", "\n"], ' ', file_get_contents($file)); $query = file_get_contents($file); $body = [ 'query' => $query @@ -157,13 +156,12 @@ trait AnilistTrait { */ public function mutateRequest (string $name, array $variables = []): Request { - $file = realpath(__DIR__ . "/GraphQL/Mutations/{$name}.graphql"); + $file = realpath(__DIR__ . "/Mutations/{$name}.graphql"); if (!file_exists($file)) { throw new LogicException('GraphQL mutation file does not exist.'); } - // $query = str_replace(["\t", "\n"], ' ', file_get_contents($file)); $query = file_get_contents($file); $body = [ diff --git a/src/AnimeClient/API/Anilist/GraphQL/Mutations/CreateFullMediaListEntry.graphql b/src/AnimeClient/API/Anilist/Mutations/CreateFullMediaListEntry.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Mutations/CreateFullMediaListEntry.graphql rename to src/AnimeClient/API/Anilist/Mutations/CreateFullMediaListEntry.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Mutations/CreateMediaListEntry.graphql b/src/AnimeClient/API/Anilist/Mutations/CreateMediaListEntry.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Mutations/CreateMediaListEntry.graphql rename to src/AnimeClient/API/Anilist/Mutations/CreateMediaListEntry.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Mutations/DeleteMediaListEntry.graphql b/src/AnimeClient/API/Anilist/Mutations/DeleteMediaListEntry.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Mutations/DeleteMediaListEntry.graphql rename to src/AnimeClient/API/Anilist/Mutations/DeleteMediaListEntry.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Mutations/IncrementMediaListEntry.graphql b/src/AnimeClient/API/Anilist/Mutations/IncrementMediaListEntry.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Mutations/IncrementMediaListEntry.graphql rename to src/AnimeClient/API/Anilist/Mutations/IncrementMediaListEntry.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Mutations/UpdateMediaListEntry.graphql b/src/AnimeClient/API/Anilist/Mutations/UpdateMediaListEntry.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Mutations/UpdateMediaListEntry.graphql rename to src/AnimeClient/API/Anilist/Mutations/UpdateMediaListEntry.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/CheckLogin.graphql b/src/AnimeClient/API/Anilist/Queries/CheckLogin.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/CheckLogin.graphql rename to src/AnimeClient/API/Anilist/Queries/CheckLogin.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/ListItemIdByMediaId.graphql b/src/AnimeClient/API/Anilist/Queries/ListItemIdByMediaId.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/ListItemIdByMediaId.graphql rename to src/AnimeClient/API/Anilist/Queries/ListItemIdByMediaId.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/MediaIdByMalId.graphql b/src/AnimeClient/API/Anilist/Queries/MediaIdByMalId.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/MediaIdByMalId.graphql rename to src/AnimeClient/API/Anilist/Queries/MediaIdByMalId.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/MediaListItem.graphql b/src/AnimeClient/API/Anilist/Queries/MediaListItem.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/MediaListItem.graphql rename to src/AnimeClient/API/Anilist/Queries/MediaListItem.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/SyncUserList.graphql b/src/AnimeClient/API/Anilist/Queries/SyncUserList.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/SyncUserList.graphql rename to src/AnimeClient/API/Anilist/Queries/SyncUserList.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/AnimeDetails.graphql b/src/AnimeClient/API/Anilist/Queries/Unused/AnimeDetails.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/AnimeDetails.graphql rename to src/AnimeClient/API/Anilist/Queries/Unused/AnimeDetails.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/ListItemIdByMalId.graphql b/src/AnimeClient/API/Anilist/Queries/Unused/ListItemIdByMalId.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/ListItemIdByMalId.graphql rename to src/AnimeClient/API/Anilist/Queries/Unused/ListItemIdByMalId.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/MangaDetails.graphql b/src/AnimeClient/API/Anilist/Queries/Unused/MangaDetails.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/MangaDetails.graphql rename to src/AnimeClient/API/Anilist/Queries/Unused/MangaDetails.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/MangaIdByMalId.graphql b/src/AnimeClient/API/Anilist/Queries/Unused/MangaIdByMalId.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/MangaIdByMalId.graphql rename to src/AnimeClient/API/Anilist/Queries/Unused/MangaIdByMalId.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/UserAnimeList.graphql b/src/AnimeClient/API/Anilist/Queries/Unused/UserAnimeList.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/UserAnimeList.graphql rename to src/AnimeClient/API/Anilist/Queries/Unused/UserAnimeList.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/UserMangaList.graphql b/src/AnimeClient/API/Anilist/Queries/Unused/UserMangaList.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/Queries/Unused/UserMangaList.graphql rename to src/AnimeClient/API/Anilist/Queries/Unused/UserMangaList.graphql diff --git a/src/AnimeClient/API/Anilist/GraphQL/schema.graphql b/src/AnimeClient/API/Anilist/schema.graphql similarity index 100% rename from src/AnimeClient/API/Anilist/GraphQL/schema.graphql rename to src/AnimeClient/API/Anilist/schema.graphql diff --git a/src/AnimeClient/API/Kitsu/.graphqlconfig b/src/AnimeClient/API/Kitsu/.graphqlconfig new file mode 100644 index 00000000..bc41639c --- /dev/null +++ b/src/AnimeClient/API/Kitsu/.graphqlconfig @@ -0,0 +1,15 @@ +{ + "name": "Kitsu Schema", + "schemaPath": "schema.graphql", + "extensions": { + "endpoints": { + "Kitsu": { + "url": "https://kitsu.io/api/graphql", + "headers": { + "user-agent": "JS GraphQL" + }, + "introspect": true + } + } + } +} \ No newline at end of file diff --git a/src/AnimeClient/API/Kitsu/GraphQL/.graphqlconfig b/src/AnimeClient/API/Kitsu/GraphQL/.graphqlconfig deleted file mode 100644 index 1d59cca6..00000000 --- a/src/AnimeClient/API/Kitsu/GraphQL/.graphqlconfig +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Kitsu Schema", - "schemaPath": "schema.graphql", - "extensions": { - "endpoints": { - "Anilist": { - "url": "https://graphql.anilist.co", - "headers": { - "user-agent": "JS GraphQL" - }, - "introspect": true - }, - "Kitsu": { - "url": "https://kitsu.io/api/graphql", - "headers": { - "user-agent": "JS GraphQL" - }, - "introspect": true - } - } - } -} \ No newline at end of file diff --git a/src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php b/src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php index db4985d4..27fdb7a2 100644 --- a/src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php +++ b/src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php @@ -193,13 +193,12 @@ final class KitsuRequestBuilder extends APIRequestBuilder { */ public function runQuery(string $name, array $variables = []): array { - $file =__DIR__ . "/GraphQL/Queries/{$name}.graphql"; + $file = __DIR__ . "/Queries/{$name}.graphql"; if ( ! file_exists($file)) { throw new LogicException('GraphQL query file does not exist.'); } - // $query = str_replace(["\t", "\n"], ' ', file_get_contents($file)); $query = file_get_contents($file); $body = [ 'query' => $query @@ -227,13 +226,12 @@ final class KitsuRequestBuilder extends APIRequestBuilder { */ public function mutateRequest (string $name, array $variables = []): Request { - $file = __DIR__ . "/GraphQL/Mutations/{$name}.graphql"; + $file = __DIR__ . "/Mutations/{$name}.graphql"; if ( ! file_exists($file)) { throw new LogicException('GraphQL mutation file does not exist.'); } - // $query = str_replace(["\t", "\n"], ' ', file_get_contents($file)); $query = file_get_contents($file); $body = [ 'query' => $query diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Mutations/IncrementLibraryItem.graphql b/src/AnimeClient/API/Kitsu/Mutations/IncrementLibraryItem.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Mutations/IncrementLibraryItem.graphql rename to src/AnimeClient/API/Kitsu/Mutations/IncrementLibraryItem.graphql diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Mutations/UpdateLibraryItem.graphql b/src/AnimeClient/API/Kitsu/Mutations/UpdateLibraryItem.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Mutations/UpdateLibraryItem.graphql rename to src/AnimeClient/API/Kitsu/Mutations/UpdateLibraryItem.graphql diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/.gitkeep b/src/AnimeClient/API/Kitsu/Queries/.gitkeep similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/.gitkeep rename to src/AnimeClient/API/Kitsu/Queries/.gitkeep diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql b/src/AnimeClient/API/Kitsu/Queries/AnimeDetails.graphql similarity index 90% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql rename to src/AnimeClient/API/Kitsu/Queries/AnimeDetails.graphql index b9f7641f..f6d1c7a3 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql +++ b/src/AnimeClient/API/Kitsu/Queries/AnimeDetails.graphql @@ -54,20 +54,6 @@ query ($slug: String!) { episodeCount episodeLength totalLength - posterImage { - original { - height - name - url - width - } - views { - height - name - url - width - } - } season sfw slug diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetailsById.graphql b/src/AnimeClient/API/Kitsu/Queries/AnimeDetailsById.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetailsById.graphql rename to src/AnimeClient/API/Kitsu/Queries/AnimeDetailsById.graphql diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/CharacterDetails.graphql b/src/AnimeClient/API/Kitsu/Queries/CharacterDetails.graphql similarity index 87% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/CharacterDetails.graphql rename to src/AnimeClient/API/Kitsu/Queries/CharacterDetails.graphql index 46872033..41e39a2f 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/CharacterDetails.graphql +++ b/src/AnimeClient/API/Kitsu/Queries/CharacterDetails.graphql @@ -18,6 +18,10 @@ query ($slug: String!) { url } } + titles { + canonical + } + type }, slug } diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetails.graphql b/src/AnimeClient/API/Kitsu/Queries/MangaDetails.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetails.graphql rename to src/AnimeClient/API/Kitsu/Queries/MangaDetails.graphql diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetailsById.graphql b/src/AnimeClient/API/Kitsu/Queries/MangaDetailsById.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetailsById.graphql rename to src/AnimeClient/API/Kitsu/Queries/MangaDetailsById.graphql diff --git a/src/AnimeClient/API/Kitsu/Queries/PersonDetails.graphql b/src/AnimeClient/API/Kitsu/Queries/PersonDetails.graphql new file mode 100644 index 00000000..9a23682e --- /dev/null +++ b/src/AnimeClient/API/Kitsu/Queries/PersonDetails.graphql @@ -0,0 +1,69 @@ +query ($id: ID!) { + findPersonById(id: $id) { + id + birthday + image { + original { + height + name + url + width + } + views { + height + name + url + width + } + } + names { + alternatives + canonical + localized + } + voices { + licensor { + name + } + locale + mediaCharacter { + role + character { + id + image { + original { + height + name + url + width + } + } + names { + canonical + } + } + media { + id + posterImage { + original { + height + name + url + width + } + views { + height + name + url + width + } + } + titles { + canonical + localized + } + } + } + } + } +} \ No newline at end of file diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/UserDetails.graphql b/src/AnimeClient/API/Kitsu/Queries/UserDetails.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/Queries/UserDetails.graphql rename to src/AnimeClient/API/Kitsu/Queries/UserDetails.graphql diff --git a/src/AnimeClient/API/Kitsu/GraphQL/schema.graphql b/src/AnimeClient/API/Kitsu/schema.graphql similarity index 100% rename from src/AnimeClient/API/Kitsu/GraphQL/schema.graphql rename to src/AnimeClient/API/Kitsu/schema.graphql