From 56a991b03b4399eae474f927c7e405fcd4168dc0 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Mon, 12 Sep 2022 16:55:30 +0100 Subject: [PATCH] Update SplatNet 3 types, log GraphQL query ID for debugging --- src/api/splatnet3-types.ts | 2 +- src/api/splatnet3.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/api/splatnet3-types.ts b/src/api/splatnet3-types.ts index 29b3175..db29234 100644 --- a/src/api/splatnet3-types.ts +++ b/src/api/splatnet3-types.ts @@ -2,7 +2,7 @@ export interface BulletToken { bulletToken: string; lang: string; - is_noe_country: 'true' | unknown; + is_noe_country: 'true' | 'false'; } /** /graphql */ diff --git a/src/api/splatnet3.ts b/src/api/splatnet3.ts index cf122d0..26c2f1b 100644 --- a/src/api/splatnet3.ts +++ b/src/api/splatnet3.ts @@ -29,7 +29,10 @@ export default class SplatNet3Api { public useragent: string, ) {} - async fetch(url: string, method = 'GET', body?: string | FormData, headers?: object) { + async fetch( + url: string, method = 'GET', body?: string | FormData, headers?: object, + /** @internal */ _log?: string + ) { const [signal, cancel] = timeoutSignal(); const response = await fetch(SPLATNET3_URL + url, { method, @@ -47,7 +50,7 @@ export default class SplatNet3Api { signal, }).finally(cancel); - debug('fetch %s %s, response %s', method, url, response.status); + debug('fetch %s %s%s, response %s', method, url, _log ? ', ' + _log : '', response.status); if (response.status !== 200) { throw new ErrorResponse('[splatnet3] Non-200 status code', response, await response.text()); @@ -69,7 +72,8 @@ export default class SplatNet3Api { }, }; - const data = await this.fetch>('/graphql', 'POST', JSON.stringify(req)); + const data = await this.fetch>('/graphql', 'POST', JSON.stringify(req), undefined, + 'graphql query ' + id); return data; }