All in GraphQL #34

Merged
timw4mail merged 87 commits from develop into master 2020-12-01 10:07:49 -05:00
33 changed files with 92 additions and 44 deletions
Showing only changes of commit 3965f137e1 - Show all commits

View File

@ -123,13 +123,12 @@ trait AnilistTrait {
*/ */
public function runQuery(string $name, array $variables = []): array 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)) if ( ! file_exists($file))
{ {
throw new LogicException('GraphQL query file does not exist.'); throw new LogicException('GraphQL query file does not exist.');
} }
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
$query = file_get_contents($file); $query = file_get_contents($file);
$body = [ $body = [
'query' => $query 'query' => $query
@ -157,13 +156,12 @@ trait AnilistTrait {
*/ */
public function mutateRequest (string $name, array $variables = []): Request 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)) if (!file_exists($file))
{ {
throw new LogicException('GraphQL mutation file does not exist.'); throw new LogicException('GraphQL mutation file does not exist.');
} }
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
$query = file_get_contents($file); $query = file_get_contents($file);
$body = [ $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 public function runQuery(string $name, array $variables = []): array
{ {
$file =__DIR__ . "/GraphQL/Queries/{$name}.graphql"; $file = __DIR__ . "/Queries/{$name}.graphql";
if ( ! file_exists($file)) if ( ! file_exists($file))
{ {
throw new LogicException('GraphQL query file does not exist.'); throw new LogicException('GraphQL query file does not exist.');
} }
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
$query = file_get_contents($file); $query = file_get_contents($file);
$body = [ $body = [
'query' => $query 'query' => $query
@ -227,13 +226,12 @@ final class KitsuRequestBuilder extends APIRequestBuilder {
*/ */
public function mutateRequest (string $name, array $variables = []): Request public function mutateRequest (string $name, array $variables = []): Request
{ {
$file = __DIR__ . "/GraphQL/Mutations/{$name}.graphql"; $file = __DIR__ . "/Mutations/{$name}.graphql";
if ( ! file_exists($file)) if ( ! file_exists($file))
{ {
throw new LogicException('GraphQL mutation file does not exist.'); throw new LogicException('GraphQL mutation file does not exist.');
} }
// $query = str_replace(["\t", "\n"], ' ', file_get_contents($file));
$query = file_get_contents($file); $query = file_get_contents($file);
$body = [ $body = [
'query' => $query 'query' => $query

View File

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

View File

@ -18,6 +18,10 @@ query ($slug: String!) {
url url
} }
} }
titles {
canonical
}
type
}, },
slug 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
}
}
}
}
}
}