Update SplatNet 3 types, log GraphQL query ID for debugging

This commit is contained in:
Samuel Elliott 2022-09-12 16:55:30 +01:00
parent 41623b1bb3
commit 56a991b03b
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 8 additions and 4 deletions

View File

@ -2,7 +2,7 @@
export interface BulletToken {
bulletToken: string;
lang: string;
is_noe_country: 'true' | unknown;
is_noe_country: 'true' | 'false';
}
/** /graphql */

View File

@ -29,7 +29,10 @@ export default class SplatNet3Api {
public useragent: string,
) {}
async fetch<T = unknown>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
async fetch<T = unknown>(
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<GraphQLResponse<T>>('/graphql', 'POST', JSON.stringify(req));
const data = await this.fetch<GraphQLResponse<T>>('/graphql', 'POST', JSON.stringify(req), undefined,
'graphql query ' + id);
return data;
}