Move GraphQL queries up a level
timw4mail/HummingBirdAnimeClient/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Timothy Warren 2020-08-04 14:25:18 -04:00
parent ff6fcffca8
commit 3965f137e1
33 changed files with 92 additions and 44 deletions

View File

@ -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 = [

View File

@ -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
}
}
}
}

View File

@ -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
}
}
}
}

View File

@ -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

View File

@ -54,20 +54,6 @@ query ($slug: String!) {
episodeCount
episodeLength
totalLength
posterImage {
original {
height
name
url
width
}
views {
height
name
url
width
}
}
season
sfw
slug

View File

@ -18,6 +18,10 @@ query ($slug: String!) {
url
}
}
titles {
canonical
}
type
},
slug
}

View File

@ -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
}
}
}
}
}
}