···
let url: URL | undefined;
-
let config: undefined | SchemaOrigin;
if (typeof schema === 'object') {
url = new URL(schema.url);
-
logger(`Fetching introspection from ${url.toString()}`);
-
fetch(url.toString(), {
...(config.headers || {}),
'Content-Type': 'application/json',
···
'Content-Type': 'application/json',
-
query: getIntrospectionQuery({
-
schemaDescription: false,
-
inputValueDeprecation: false,
-
directiveIsRepeatable: false,
-
logger(`Got response ${response.statusText} ${response.status}`);
-
if (response.ok) return response.json();
-
else return response.text();
-
logger(`Got result ${JSON.stringify(result)}`);
-
if (typeof result === 'string') {
-
logger(`Got error while fetching introspection ${result}`);
-
} else if (result.data) {
-
ref.current = buildClientSchema(
-
(result as { data: IntrospectionQuery }).data
-
ref.version = ref.version + 1;
-
logger(`Got schema for ${url!.toString()}`);
-
logger(`Got schema error for ${e.message}`);
-
logger(`Got invalid response ${JSON.stringify(result)}`);
} else if (typeof schema === 'string') {
const isJson = schema.endsWith('json');
const resolvedPath = path.resolve(path.dirname(root), schema);
···
let url: URL | undefined;
+
let config: { headers: Record<string, unknown> } | undefined;
if (typeof schema === 'object') {
url = new URL(schema.url);
+
config = { headers: schema.headers };
+
const pollSchema = () => {
+
logger(`Fetching introspection from ${url!.toString()}`);
+
fetch(url!.toString(), {
...(config.headers || {}),
'Content-Type': 'application/json',
···
'Content-Type': 'application/json',
+
query: getIntrospectionQuery({
+
schemaDescription: false,
+
inputValueDeprecation: false,
+
directiveIsRepeatable: false,
+
logger(`Got response ${response.statusText} ${response.status}`);
+
if (response.ok) return response.json();
+
else return response.text();
+
logger(`Got result ${JSON.stringify(result)}`);
+
if (typeof result === 'string') {
+
logger(`Got error while fetching introspection ${result}`);
+
} else if (result.data) {
+
ref.current = buildClientSchema(
+
(result as { data: IntrospectionQuery }).data
+
ref.version = ref.version + 1;
+
logger(`Got schema for ${url!.toString()}`);
+
logger(`Got schema error for ${e.message}`);
+
logger(`Got invalid response ${JSON.stringify(result)}`);
} else if (typeof schema === 'string') {
const isJson = schema.endsWith('json');
const resolvedPath = path.resolve(path.dirname(root), schema);