houdini 1.2.48 → 1.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  export default function (args: {
2
2
  headers: string[];
3
+ output?: string;
3
4
  }): Promise<void>;
@@ -64997,10 +64997,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
64997
64997
  }
64998
64998
 
64999
64999
  // src/lib/introspection.ts
65000
- async function pullSchema(url, schemaPath, headers, skipWriting) {
65000
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
65001
65001
  let content = "";
65002
65002
  try {
65003
- const resp = await fetch(url, {
65003
+ const fetchWithTimeout = (url2, timeoutMs, options) => {
65004
+ const controller = new AbortController();
65005
+ const promise = fetch(url2, {
65006
+ signal: controller.signal,
65007
+ ...options
65008
+ });
65009
+ const timeout = setTimeout(() => {
65010
+ controller.abort();
65011
+ }, timeoutMs);
65012
+ return promise.catch((err) => {
65013
+ if (err.type === "aborted") {
65014
+ throw Error(
65015
+ `reached timeout of ${timeoutMs}ms. Make sure the API is available and tweak this timeout in your config if your API is slow to respond.`
65016
+ );
65017
+ } else {
65018
+ return err;
65019
+ }
65020
+ }).finally(() => clearTimeout(timeout));
65021
+ };
65022
+ const resp = await fetchWithTimeout(url, fetchTimeout, {
65004
65023
  method: "POST",
65005
65024
  body: JSON.stringify({
65006
65025
  query: graphql.getIntrospectionQuery()
@@ -66930,7 +66949,13 @@ var CacheInternal = class {
66930
66949
  } else if (!fieldSelection) {
66931
66950
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
66932
66951
  if (fnUnmarshal) {
66933
- fieldTarget[attributeName] = fnUnmarshal(value);
66952
+ if (Array.isArray(value)) {
66953
+ fieldTarget[attributeName] = value.map(
66954
+ (v2) => fnUnmarshal(v2)
66955
+ );
66956
+ } else {
66957
+ fieldTarget[attributeName] = fnUnmarshal(value);
66958
+ }
66934
66959
  } else {
66935
66960
  fieldTarget[attributeName] = value;
66936
66961
  }
@@ -67298,6 +67323,7 @@ var Config = class {
67298
67323
  configIsRoute = null;
67299
67324
  routesDir;
67300
67325
  schemaPollInterval;
67326
+ schemaPollTimeout;
67301
67327
  schemaPollHeaders;
67302
67328
  pluginMode = false;
67303
67329
  plugins = [];
@@ -67367,6 +67393,7 @@ var Config = class {
67367
67393
  this.defaultFragmentMasking = defaultFragmentMasking;
67368
67394
  this.routesDir = join2(this.projectRoot, "src", "routes");
67369
67395
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
67396
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
67370
67397
  this.schemaPollHeaders = watchSchema?.headers ?? {};
67371
67398
  this.rootDir = join2(this.projectRoot, "$houdini");
67372
67399
  this.#fragmentVariableMaps = {};
@@ -68005,7 +68032,11 @@ async function getConfig({
68005
68032
  );
68006
68033
  } else if (!await readFile(_config.schemaPath)) {
68007
68034
  console.log("\u231B Pulling schema from api");
68008
- schemaOk = await pullSchema(apiURL, _config.schemaPath) !== null;
68035
+ schemaOk = await pullSchema(
68036
+ apiURL,
68037
+ _config.schemaPollTimeout,
68038
+ _config.schemaPath
68039
+ ) !== null;
68009
68040
  }
68010
68041
  }
68011
68042
  if (schemaOk && !noSchema) {
@@ -77031,7 +77062,6 @@ async function pullSchema_default(args) {
77031
77062
  process.exit(1);
77032
77063
  return;
77033
77064
  }
77034
- const targetPath = process.cwd();
77035
77065
  let headers = await config.pullHeaders();
77036
77066
  let headerStrings = [];
77037
77067
  if (args.headers) {
@@ -77046,7 +77076,8 @@ async function pullSchema_default(args) {
77046
77076
  };
77047
77077
  }, headers);
77048
77078
  }
77049
- await pullSchema(apiURL, config.schemaPath ?? path_exports.resolve(targetPath, "schema.json"), headers);
77079
+ const targetPath = args.output ? path_exports.resolve(args.output) : config.schemaPath ?? path_exports.resolve(process.cwd(), "schema.json");
77080
+ await pullSchema(apiURL, config.schemaPollTimeout, targetPath, headers);
77050
77081
  }
77051
77082
 
77052
77083
  // src/cmd/generate.ts
@@ -77740,7 +77771,14 @@ async function init2(_path, args) {
77740
77771
  const value_splited = url_and_headers.split(" ");
77741
77772
  const local_url = value_splited[0];
77742
77773
  const local_headers = value_splited.length > 1 ? extractHeadersStr(value_splited.slice(1).join(" ")) : headers;
77743
- pullSchema_content = await pullSchema(local_url, schemaPath, local_headers, true);
77774
+ const fetchTimeout = 3e4;
77775
+ pullSchema_content = await pullSchema(
77776
+ local_url,
77777
+ fetchTimeout,
77778
+ schemaPath,
77779
+ local_headers,
77780
+ true
77781
+ );
77744
77782
  if (pullSchema_content === null) {
77745
77783
  const msg = `If you need to pass headers, add them after the URL (eg: '${green3(
77746
77784
  `http://myurl.com/graphql Authorization=Bearer MyToken`
@@ -78053,12 +78091,12 @@ async function packageJSON(targetPath, frameworkInfo) {
78053
78091
  }
78054
78092
  packageJSON2.devDependencies = {
78055
78093
  ...packageJSON2.devDependencies,
78056
- houdini: "^1.2.48"
78094
+ houdini: "^1.2.49"
78057
78095
  };
78058
78096
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
78059
78097
  packageJSON2.devDependencies = {
78060
78098
  ...packageJSON2.devDependencies,
78061
- "houdini-svelte": "^1.2.48"
78099
+ "houdini-svelte": "^1.2.49"
78062
78100
  };
78063
78101
  } else {
78064
78102
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -78079,7 +78117,7 @@ program2.command("init").arguments("[path]").usage("[path] [options]").descripti
78079
78117
  "-h, --headers <headers...>",
78080
78118
  "header to use when pulling your schema. Should be passed as KEY=VALUE"
78081
78119
  ).option("-y, --yes", "dont prompt for input. uses default values or empty strings").action(init2);
78082
- program2.command("pull-schema").usage("[options]").description("pull the latest schema from your api").option(
78120
+ program2.command("pull-schema").usage("[options]").description("pull the latest schema from your api").option("-o, --output [outputPath]", "the destination for the schema contents").option(
78083
78121
  "-h, --headers <headers...>",
78084
78122
  "headers to use when pulling your schema. Should be passed as KEY=VALUE"
78085
78123
  ).action(pullSchema_default);
@@ -65003,10 +65003,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
65003
65003
  }
65004
65004
 
65005
65005
  // src/lib/introspection.ts
65006
- async function pullSchema(url, schemaPath, headers, skipWriting) {
65006
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
65007
65007
  let content = "";
65008
65008
  try {
65009
- const resp = await fetch(url, {
65009
+ const fetchWithTimeout = (url2, timeoutMs, options) => {
65010
+ const controller = new AbortController();
65011
+ const promise = fetch(url2, {
65012
+ signal: controller.signal,
65013
+ ...options
65014
+ });
65015
+ const timeout = setTimeout(() => {
65016
+ controller.abort();
65017
+ }, timeoutMs);
65018
+ return promise.catch((err) => {
65019
+ if (err.type === "aborted") {
65020
+ throw Error(
65021
+ `reached timeout of ${timeoutMs}ms. Make sure the API is available and tweak this timeout in your config if your API is slow to respond.`
65022
+ );
65023
+ } else {
65024
+ return err;
65025
+ }
65026
+ }).finally(() => clearTimeout(timeout));
65027
+ };
65028
+ const resp = await fetchWithTimeout(url, fetchTimeout, {
65010
65029
  method: "POST",
65011
65030
  body: JSON.stringify({
65012
65031
  query: graphql.getIntrospectionQuery()
@@ -66936,7 +66955,13 @@ var CacheInternal = class {
66936
66955
  } else if (!fieldSelection) {
66937
66956
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
66938
66957
  if (fnUnmarshal) {
66939
- fieldTarget[attributeName] = fnUnmarshal(value);
66958
+ if (Array.isArray(value)) {
66959
+ fieldTarget[attributeName] = value.map(
66960
+ (v2) => fnUnmarshal(v2)
66961
+ );
66962
+ } else {
66963
+ fieldTarget[attributeName] = fnUnmarshal(value);
66964
+ }
66940
66965
  } else {
66941
66966
  fieldTarget[attributeName] = value;
66942
66967
  }
@@ -67303,6 +67328,7 @@ var Config = class {
67303
67328
  configIsRoute = null;
67304
67329
  routesDir;
67305
67330
  schemaPollInterval;
67331
+ schemaPollTimeout;
67306
67332
  schemaPollHeaders;
67307
67333
  pluginMode = false;
67308
67334
  plugins = [];
@@ -67372,6 +67398,7 @@ var Config = class {
67372
67398
  this.defaultFragmentMasking = defaultFragmentMasking;
67373
67399
  this.routesDir = join2(this.projectRoot, "src", "routes");
67374
67400
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
67401
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
67375
67402
  this.schemaPollHeaders = watchSchema?.headers ?? {};
67376
67403
  this.rootDir = join2(this.projectRoot, "$houdini");
67377
67404
  this.#fragmentVariableMaps = {};
@@ -68010,7 +68037,11 @@ async function getConfig({
68010
68037
  );
68011
68038
  } else if (!await readFile(_config.schemaPath)) {
68012
68039
  console.log("\u231B Pulling schema from api");
68013
- schemaOk = await pullSchema(apiURL, _config.schemaPath) !== null;
68040
+ schemaOk = await pullSchema(
68041
+ apiURL,
68042
+ _config.schemaPollTimeout,
68043
+ _config.schemaPath
68044
+ ) !== null;
68014
68045
  }
68015
68046
  }
68016
68047
  if (schemaOk && !noSchema) {
@@ -77036,7 +77067,6 @@ async function pullSchema_default(args) {
77036
77067
  process.exit(1);
77037
77068
  return;
77038
77069
  }
77039
- const targetPath = process.cwd();
77040
77070
  let headers = await config.pullHeaders();
77041
77071
  let headerStrings = [];
77042
77072
  if (args.headers) {
@@ -77051,7 +77081,8 @@ async function pullSchema_default(args) {
77051
77081
  };
77052
77082
  }, headers);
77053
77083
  }
77054
- await pullSchema(apiURL, config.schemaPath ?? path_exports.resolve(targetPath, "schema.json"), headers);
77084
+ const targetPath = args.output ? path_exports.resolve(args.output) : config.schemaPath ?? path_exports.resolve(process.cwd(), "schema.json");
77085
+ await pullSchema(apiURL, config.schemaPollTimeout, targetPath, headers);
77055
77086
  }
77056
77087
 
77057
77088
  // src/cmd/generate.ts
@@ -77745,7 +77776,14 @@ async function init2(_path, args) {
77745
77776
  const value_splited = url_and_headers.split(" ");
77746
77777
  const local_url = value_splited[0];
77747
77778
  const local_headers = value_splited.length > 1 ? extractHeadersStr(value_splited.slice(1).join(" ")) : headers;
77748
- pullSchema_content = await pullSchema(local_url, schemaPath, local_headers, true);
77779
+ const fetchTimeout = 3e4;
77780
+ pullSchema_content = await pullSchema(
77781
+ local_url,
77782
+ fetchTimeout,
77783
+ schemaPath,
77784
+ local_headers,
77785
+ true
77786
+ );
77749
77787
  if (pullSchema_content === null) {
77750
77788
  const msg = `If you need to pass headers, add them after the URL (eg: '${green3(
77751
77789
  `http://myurl.com/graphql Authorization=Bearer MyToken`
@@ -78058,12 +78096,12 @@ async function packageJSON(targetPath, frameworkInfo) {
78058
78096
  }
78059
78097
  packageJSON2.devDependencies = {
78060
78098
  ...packageJSON2.devDependencies,
78061
- houdini: "^1.2.48"
78099
+ houdini: "^1.2.49"
78062
78100
  };
78063
78101
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
78064
78102
  packageJSON2.devDependencies = {
78065
78103
  ...packageJSON2.devDependencies,
78066
- "houdini-svelte": "^1.2.48"
78104
+ "houdini-svelte": "^1.2.49"
78067
78105
  };
78068
78106
  } else {
78069
78107
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -78084,7 +78122,7 @@ program2.command("init").arguments("[path]").usage("[path] [options]").descripti
78084
78122
  "-h, --headers <headers...>",
78085
78123
  "header to use when pulling your schema. Should be passed as KEY=VALUE"
78086
78124
  ).option("-y, --yes", "dont prompt for input. uses default values or empty strings").action(init2);
78087
- program2.command("pull-schema").usage("[options]").description("pull the latest schema from your api").option(
78125
+ program2.command("pull-schema").usage("[options]").description("pull the latest schema from your api").option("-o, --output [outputPath]", "the destination for the schema contents").option(
78088
78126
  "-h, --headers <headers...>",
78089
78127
  "headers to use when pulling your schema. Should be passed as KEY=VALUE"
78090
78128
  ).action(pullSchema_default);
@@ -56304,7 +56304,13 @@ var CacheInternal = class {
56304
56304
  } else if (!fieldSelection) {
56305
56305
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
56306
56306
  if (fnUnmarshal) {
56307
- fieldTarget[attributeName] = fnUnmarshal(value);
56307
+ if (Array.isArray(value)) {
56308
+ fieldTarget[attributeName] = value.map(
56309
+ (v) => fnUnmarshal(v)
56310
+ );
56311
+ } else {
56312
+ fieldTarget[attributeName] = fnUnmarshal(value);
56313
+ }
56308
56314
  } else {
56309
56315
  fieldTarget[attributeName] = value;
56310
56316
  }
@@ -56304,7 +56304,13 @@ var CacheInternal = class {
56304
56304
  } else if (!fieldSelection) {
56305
56305
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
56306
56306
  if (fnUnmarshal) {
56307
- fieldTarget[attributeName] = fnUnmarshal(value);
56307
+ if (Array.isArray(value)) {
56308
+ fieldTarget[attributeName] = value.map(
56309
+ (v) => fnUnmarshal(v)
56310
+ );
56311
+ } else {
56312
+ fieldTarget[attributeName] = fnUnmarshal(value);
56313
+ }
56308
56314
  } else {
56309
56315
  fieldTarget[attributeName] = value;
56310
56316
  }
@@ -33,6 +33,7 @@ export declare class Config {
33
33
  configIsRoute: ((filepath: string) => boolean) | null;
34
34
  routesDir: string;
35
35
  schemaPollInterval: number | null;
36
+ schemaPollTimeout: number;
36
37
  schemaPollHeaders: ((env: any) => Record<string, string>) | Record<string, string | ((env: any) => string)>;
37
38
  pluginMode: boolean;
38
39
  plugins: PluginMeta[];
@@ -1,3 +1,3 @@
1
- export declare function pullSchema(url: string, schemaPath: string, headers?: Record<string, string>, skipWriting?: boolean): Promise<string | null>;
1
+ export declare function pullSchema(url: string, fetchTimeout: number, schemaPath: string, headers?: Record<string, string>, skipWriting?: boolean): Promise<string | null>;
2
2
  export declare function extractHeadersStr(str: string | undefined): Record<string, string>;
3
3
  export declare function extractHeaders(headers?: string[] | undefined): {};
@@ -61592,7 +61592,7 @@ async function marshalSelection({
61592
61592
  const marshalFn = config.scalars[type].marshal;
61593
61593
  if (!marshalFn) {
61594
61594
  throw new Error(
61595
- `scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
61595
+ `Scalar type ${type} is missing a \`marshal\` function. See https://houdinigraphql.com/api/config#custom-scalars for help on configuring custom scalars.`
61596
61596
  );
61597
61597
  }
61598
61598
  if (Array.isArray(value)) {
@@ -63389,10 +63389,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
63389
63389
  }
63390
63390
 
63391
63391
  // src/lib/introspection.ts
63392
- async function pullSchema(url, schemaPath, headers, skipWriting) {
63392
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
63393
63393
  let content = "";
63394
63394
  try {
63395
- const resp = await fetch(url, {
63395
+ const fetchWithTimeout = (url2, timeoutMs, options) => {
63396
+ const controller = new AbortController();
63397
+ const promise = fetch(url2, {
63398
+ signal: controller.signal,
63399
+ ...options
63400
+ });
63401
+ const timeout = setTimeout(() => {
63402
+ controller.abort();
63403
+ }, timeoutMs);
63404
+ return promise.catch((err) => {
63405
+ if (err.type === "aborted") {
63406
+ throw Error(
63407
+ `reached timeout of ${timeoutMs}ms. Make sure the API is available and tweak this timeout in your config if your API is slow to respond.`
63408
+ );
63409
+ } else {
63410
+ return err;
63411
+ }
63412
+ }).finally(() => clearTimeout(timeout));
63413
+ };
63414
+ const resp = await fetchWithTimeout(url, fetchTimeout, {
63396
63415
  method: "POST",
63397
63416
  body: JSON.stringify({
63398
63417
  query: graphql.getIntrospectionQuery()
@@ -65322,7 +65341,13 @@ var CacheInternal = class {
65322
65341
  } else if (!fieldSelection) {
65323
65342
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
65324
65343
  if (fnUnmarshal) {
65325
- fieldTarget[attributeName] = fnUnmarshal(value);
65344
+ if (Array.isArray(value)) {
65345
+ fieldTarget[attributeName] = value.map(
65346
+ (v) => fnUnmarshal(v)
65347
+ );
65348
+ } else {
65349
+ fieldTarget[attributeName] = fnUnmarshal(value);
65350
+ }
65326
65351
  } else {
65327
65352
  fieldTarget[attributeName] = value;
65328
65353
  }
@@ -66752,6 +66777,7 @@ var Config = class {
66752
66777
  configIsRoute = null;
66753
66778
  routesDir;
66754
66779
  schemaPollInterval;
66780
+ schemaPollTimeout;
66755
66781
  schemaPollHeaders;
66756
66782
  pluginMode = false;
66757
66783
  plugins = [];
@@ -66821,6 +66847,7 @@ var Config = class {
66821
66847
  this.defaultFragmentMasking = defaultFragmentMasking;
66822
66848
  this.routesDir = join2(this.projectRoot, "src", "routes");
66823
66849
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
66850
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
66824
66851
  this.schemaPollHeaders = watchSchema?.headers ?? {};
66825
66852
  this.rootDir = join2(this.projectRoot, "$houdini");
66826
66853
  this.#fragmentVariableMaps = {};
@@ -67459,7 +67486,11 @@ async function getConfig({
67459
67486
  );
67460
67487
  } else if (!await readFile(_config.schemaPath)) {
67461
67488
  console.log("\u231B Pulling schema from api");
67462
- schemaOk = await pullSchema(apiURL, _config.schemaPath) !== null;
67489
+ schemaOk = await pullSchema(
67490
+ apiURL,
67491
+ _config.schemaPollTimeout,
67492
+ _config.schemaPath
67493
+ ) !== null;
67463
67494
  }
67464
67495
  }
67465
67496
  if (schemaOk && !noSchema) {
@@ -61508,7 +61508,7 @@ async function marshalSelection({
61508
61508
  const marshalFn = config.scalars[type].marshal;
61509
61509
  if (!marshalFn) {
61510
61510
  throw new Error(
61511
- `scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
61511
+ `Scalar type ${type} is missing a \`marshal\` function. See https://houdinigraphql.com/api/config#custom-scalars for help on configuring custom scalars.`
61512
61512
  );
61513
61513
  }
61514
61514
  if (Array.isArray(value)) {
@@ -63305,10 +63305,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
63305
63305
  }
63306
63306
 
63307
63307
  // src/lib/introspection.ts
63308
- async function pullSchema(url, schemaPath, headers, skipWriting) {
63308
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
63309
63309
  let content = "";
63310
63310
  try {
63311
- const resp = await fetch(url, {
63311
+ const fetchWithTimeout = (url2, timeoutMs, options) => {
63312
+ const controller = new AbortController();
63313
+ const promise = fetch(url2, {
63314
+ signal: controller.signal,
63315
+ ...options
63316
+ });
63317
+ const timeout = setTimeout(() => {
63318
+ controller.abort();
63319
+ }, timeoutMs);
63320
+ return promise.catch((err) => {
63321
+ if (err.type === "aborted") {
63322
+ throw Error(
63323
+ `reached timeout of ${timeoutMs}ms. Make sure the API is available and tweak this timeout in your config if your API is slow to respond.`
63324
+ );
63325
+ } else {
63326
+ return err;
63327
+ }
63328
+ }).finally(() => clearTimeout(timeout));
63329
+ };
63330
+ const resp = await fetchWithTimeout(url, fetchTimeout, {
63312
63331
  method: "POST",
63313
63332
  body: JSON.stringify({
63314
63333
  query: graphql.getIntrospectionQuery()
@@ -65238,7 +65257,13 @@ var CacheInternal = class {
65238
65257
  } else if (!fieldSelection) {
65239
65258
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
65240
65259
  if (fnUnmarshal) {
65241
- fieldTarget[attributeName] = fnUnmarshal(value);
65260
+ if (Array.isArray(value)) {
65261
+ fieldTarget[attributeName] = value.map(
65262
+ (v) => fnUnmarshal(v)
65263
+ );
65264
+ } else {
65265
+ fieldTarget[attributeName] = fnUnmarshal(value);
65266
+ }
65242
65267
  } else {
65243
65268
  fieldTarget[attributeName] = value;
65244
65269
  }
@@ -66667,6 +66692,7 @@ var Config = class {
66667
66692
  configIsRoute = null;
66668
66693
  routesDir;
66669
66694
  schemaPollInterval;
66695
+ schemaPollTimeout;
66670
66696
  schemaPollHeaders;
66671
66697
  pluginMode = false;
66672
66698
  plugins = [];
@@ -66736,6 +66762,7 @@ var Config = class {
66736
66762
  this.defaultFragmentMasking = defaultFragmentMasking;
66737
66763
  this.routesDir = join2(this.projectRoot, "src", "routes");
66738
66764
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
66765
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
66739
66766
  this.schemaPollHeaders = watchSchema?.headers ?? {};
66740
66767
  this.rootDir = join2(this.projectRoot, "$houdini");
66741
66768
  this.#fragmentVariableMaps = {};
@@ -67374,7 +67401,11 @@ async function getConfig({
67374
67401
  );
67375
67402
  } else if (!await readFile(_config.schemaPath)) {
67376
67403
  console.log("\u231B Pulling schema from api");
67377
- schemaOk = await pullSchema(apiURL, _config.schemaPath) !== null;
67404
+ schemaOk = await pullSchema(
67405
+ apiURL,
67406
+ _config.schemaPollTimeout,
67407
+ _config.schemaPath
67408
+ ) !== null;
67378
67409
  }
67379
67410
  }
67380
67411
  if (schemaOk && !noSchema) {
@@ -174,6 +174,12 @@ export type WatchSchemaConfig = {
174
174
  * To disable the schema introspection, set interval to null.
175
175
  */
176
176
  interval?: number | null;
177
+ /**
178
+ * Sets a custom timeout in milliseconds which is used to cancel fetching the schema. If the timeout is reached
179
+ * before the remote API has responded, the request is cancelled and an error is displayed.
180
+ * The default is 30 seconds (30000 milliseconds)
181
+ */
182
+ timeout?: number | null;
177
183
  /**
178
184
  * An object containing the environment variables you want passed onto the api when polling for a new schema.
179
185
  * The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
@@ -647,7 +647,13 @@ class CacheInternal {
647
647
  } else if (!fieldSelection) {
648
648
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
649
649
  if (fnUnmarshal) {
650
- fieldTarget[attributeName] = fnUnmarshal(value);
650
+ if (Array.isArray(value)) {
651
+ fieldTarget[attributeName] = value.map(
652
+ (v) => fnUnmarshal(v)
653
+ );
654
+ } else {
655
+ fieldTarget[attributeName] = fnUnmarshal(value);
656
+ }
651
657
  } else {
652
658
  fieldTarget[attributeName] = value;
653
659
  }
@@ -174,6 +174,12 @@ export type WatchSchemaConfig = {
174
174
  * To disable the schema introspection, set interval to null.
175
175
  */
176
176
  interval?: number | null;
177
+ /**
178
+ * Sets a custom timeout in milliseconds which is used to cancel fetching the schema. If the timeout is reached
179
+ * before the remote API has responded, the request is cancelled and an error is displayed.
180
+ * The default is 30 seconds (30000 milliseconds)
181
+ */
182
+ timeout?: number | null;
177
183
  /**
178
184
  * An object containing the environment variables you want passed onto the api when polling for a new schema.
179
185
  * The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
@@ -56,7 +56,7 @@ async function marshalSelection({
56
56
  const marshalFn = config.scalars[type].marshal;
57
57
  if (!marshalFn) {
58
58
  throw new Error(
59
- `scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
59
+ `Scalar type ${type} is missing a \`marshal\` function. See https://houdinigraphql.com/api/config#custom-scalars for help on configuring custom scalars.`
60
60
  );
61
61
  }
62
62
  if (Array.isArray(value)) {
@@ -619,7 +619,13 @@ class CacheInternal {
619
619
  } else if (!fieldSelection) {
620
620
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
621
621
  if (fnUnmarshal) {
622
- fieldTarget[attributeName] = fnUnmarshal(value);
622
+ if (Array.isArray(value)) {
623
+ fieldTarget[attributeName] = value.map(
624
+ (v) => fnUnmarshal(v)
625
+ );
626
+ } else {
627
+ fieldTarget[attributeName] = fnUnmarshal(value);
628
+ }
623
629
  } else {
624
630
  fieldTarget[attributeName] = value;
625
631
  }
@@ -174,6 +174,12 @@ export type WatchSchemaConfig = {
174
174
  * To disable the schema introspection, set interval to null.
175
175
  */
176
176
  interval?: number | null;
177
+ /**
178
+ * Sets a custom timeout in milliseconds which is used to cancel fetching the schema. If the timeout is reached
179
+ * before the remote API has responded, the request is cancelled and an error is displayed.
180
+ * The default is 30 seconds (30000 milliseconds)
181
+ */
182
+ timeout?: number | null;
177
183
  /**
178
184
  * An object containing the environment variables you want passed onto the api when polling for a new schema.
179
185
  * The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
@@ -32,7 +32,7 @@ async function marshalSelection({
32
32
  const marshalFn = config.scalars[type].marshal;
33
33
  if (!marshalFn) {
34
34
  throw new Error(
35
- `scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
35
+ `Scalar type ${type} is missing a \`marshal\` function. See https://houdinigraphql.com/api/config#custom-scalars for help on configuring custom scalars.`
36
36
  );
37
37
  }
38
38
  if (Array.isArray(value)) {
@@ -56314,7 +56314,13 @@ var CacheInternal = class {
56314
56314
  } else if (!fieldSelection) {
56315
56315
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
56316
56316
  if (fnUnmarshal) {
56317
- fieldTarget[attributeName] = fnUnmarshal(value);
56317
+ if (Array.isArray(value)) {
56318
+ fieldTarget[attributeName] = value.map(
56319
+ (v) => fnUnmarshal(v)
56320
+ );
56321
+ } else {
56322
+ fieldTarget[attributeName] = fnUnmarshal(value);
56323
+ }
56318
56324
  } else {
56319
56325
  fieldTarget[attributeName] = value;
56320
56326
  }
@@ -56682,6 +56688,7 @@ var Config = class {
56682
56688
  configIsRoute = null;
56683
56689
  routesDir;
56684
56690
  schemaPollInterval;
56691
+ schemaPollTimeout;
56685
56692
  schemaPollHeaders;
56686
56693
  pluginMode = false;
56687
56694
  plugins = [];
@@ -56751,6 +56758,7 @@ var Config = class {
56751
56758
  this.defaultFragmentMasking = defaultFragmentMasking;
56752
56759
  this.routesDir = join(this.projectRoot, "src", "routes");
56753
56760
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
56761
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
56754
56762
  this.schemaPollHeaders = watchSchema?.headers ?? {};
56755
56763
  this.rootDir = join(this.projectRoot, "$houdini");
56756
56764
  this.#fragmentVariableMaps = {};
@@ -56311,7 +56311,13 @@ var CacheInternal = class {
56311
56311
  } else if (!fieldSelection) {
56312
56312
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
56313
56313
  if (fnUnmarshal) {
56314
- fieldTarget[attributeName] = fnUnmarshal(value);
56314
+ if (Array.isArray(value)) {
56315
+ fieldTarget[attributeName] = value.map(
56316
+ (v) => fnUnmarshal(v)
56317
+ );
56318
+ } else {
56319
+ fieldTarget[attributeName] = fnUnmarshal(value);
56320
+ }
56315
56321
  } else {
56316
56322
  fieldTarget[attributeName] = value;
56317
56323
  }
@@ -56678,6 +56684,7 @@ var Config = class {
56678
56684
  configIsRoute = null;
56679
56685
  routesDir;
56680
56686
  schemaPollInterval;
56687
+ schemaPollTimeout;
56681
56688
  schemaPollHeaders;
56682
56689
  pluginMode = false;
56683
56690
  plugins = [];
@@ -56747,6 +56754,7 @@ var Config = class {
56747
56754
  this.defaultFragmentMasking = defaultFragmentMasking;
56748
56755
  this.routesDir = join(this.projectRoot, "src", "routes");
56749
56756
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
56757
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
56750
56758
  this.schemaPollHeaders = watchSchema?.headers ?? {};
56751
56759
  this.rootDir = join(this.projectRoot, "$houdini");
56752
56760
  this.#fragmentVariableMaps = {};
@@ -66158,10 +66158,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
66158
66158
  }
66159
66159
 
66160
66160
  // src/lib/introspection.ts
66161
- async function pullSchema(url, schemaPath, headers, skipWriting) {
66161
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
66162
66162
  let content = "";
66163
66163
  try {
66164
- const resp = await fetch(url, {
66164
+ const fetchWithTimeout = (url2, timeoutMs, options) => {
66165
+ const controller = new AbortController();
66166
+ const promise = fetch(url2, {
66167
+ signal: controller.signal,
66168
+ ...options
66169
+ });
66170
+ const timeout = setTimeout(() => {
66171
+ controller.abort();
66172
+ }, timeoutMs);
66173
+ return promise.catch((err) => {
66174
+ if (err.type === "aborted") {
66175
+ throw Error(
66176
+ `reached timeout of ${timeoutMs}ms. Make sure the API is available and tweak this timeout in your config if your API is slow to respond.`
66177
+ );
66178
+ } else {
66179
+ return err;
66180
+ }
66181
+ }).finally(() => clearTimeout(timeout));
66182
+ };
66183
+ const resp = await fetchWithTimeout(url, fetchTimeout, {
66165
66184
  method: "POST",
66166
66185
  body: JSON.stringify({
66167
66186
  query: graphql.getIntrospectionQuery()
@@ -68070,7 +68089,13 @@ var CacheInternal = class {
68070
68089
  } else if (!fieldSelection) {
68071
68090
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
68072
68091
  if (fnUnmarshal) {
68073
- fieldTarget[attributeName] = fnUnmarshal(value);
68092
+ if (Array.isArray(value)) {
68093
+ fieldTarget[attributeName] = value.map(
68094
+ (v) => fnUnmarshal(v)
68095
+ );
68096
+ } else {
68097
+ fieldTarget[attributeName] = fnUnmarshal(value);
68098
+ }
68074
68099
  } else {
68075
68100
  fieldTarget[attributeName] = value;
68076
68101
  }
@@ -68438,6 +68463,7 @@ var Config = class {
68438
68463
  configIsRoute = null;
68439
68464
  routesDir;
68440
68465
  schemaPollInterval;
68466
+ schemaPollTimeout;
68441
68467
  schemaPollHeaders;
68442
68468
  pluginMode = false;
68443
68469
  plugins = [];
@@ -68507,6 +68533,7 @@ var Config = class {
68507
68533
  this.defaultFragmentMasking = defaultFragmentMasking;
68508
68534
  this.routesDir = join2(this.projectRoot, "src", "routes");
68509
68535
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
68536
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
68510
68537
  this.schemaPollHeaders = watchSchema?.headers ?? {};
68511
68538
  this.rootDir = join2(this.projectRoot, "$houdini");
68512
68539
  this.#fragmentVariableMaps = {};
@@ -69145,7 +69172,11 @@ async function getConfig({
69145
69172
  );
69146
69173
  } else if (!await readFile(_config.schemaPath)) {
69147
69174
  console.log("\u231B Pulling schema from api");
69148
- schemaOk = await pullSchema(apiURL, _config.schemaPath) !== null;
69175
+ schemaOk = await pullSchema(
69176
+ apiURL,
69177
+ _config.schemaPollTimeout,
69178
+ _config.schemaPath
69179
+ ) !== null;
69149
69180
  }
69150
69181
  }
69151
69182
  if (schemaOk && !noSchema) {
@@ -78794,6 +78825,7 @@ function watch_remote_schema(opts = {}) {
78794
78825
  try {
78795
78826
  const schemaState = await pullSchema(
78796
78827
  apiURL,
78828
+ config2.schemaPollTimeout,
78797
78829
  config2.schemaPath ?? path_exports.resolve(process.cwd(), "schema.json"),
78798
78830
  await config2.pullHeaders()
78799
78831
  );
@@ -66152,10 +66152,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
66152
66152
  }
66153
66153
 
66154
66154
  // src/lib/introspection.ts
66155
- async function pullSchema(url, schemaPath, headers, skipWriting) {
66155
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
66156
66156
  let content = "";
66157
66157
  try {
66158
- const resp = await fetch(url, {
66158
+ const fetchWithTimeout = (url2, timeoutMs, options) => {
66159
+ const controller = new AbortController();
66160
+ const promise = fetch(url2, {
66161
+ signal: controller.signal,
66162
+ ...options
66163
+ });
66164
+ const timeout = setTimeout(() => {
66165
+ controller.abort();
66166
+ }, timeoutMs);
66167
+ return promise.catch((err) => {
66168
+ if (err.type === "aborted") {
66169
+ throw Error(
66170
+ `reached timeout of ${timeoutMs}ms. Make sure the API is available and tweak this timeout in your config if your API is slow to respond.`
66171
+ );
66172
+ } else {
66173
+ return err;
66174
+ }
66175
+ }).finally(() => clearTimeout(timeout));
66176
+ };
66177
+ const resp = await fetchWithTimeout(url, fetchTimeout, {
66159
66178
  method: "POST",
66160
66179
  body: JSON.stringify({
66161
66180
  query: graphql.getIntrospectionQuery()
@@ -68064,7 +68083,13 @@ var CacheInternal = class {
68064
68083
  } else if (!fieldSelection) {
68065
68084
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
68066
68085
  if (fnUnmarshal) {
68067
- fieldTarget[attributeName] = fnUnmarshal(value);
68086
+ if (Array.isArray(value)) {
68087
+ fieldTarget[attributeName] = value.map(
68088
+ (v) => fnUnmarshal(v)
68089
+ );
68090
+ } else {
68091
+ fieldTarget[attributeName] = fnUnmarshal(value);
68092
+ }
68068
68093
  } else {
68069
68094
  fieldTarget[attributeName] = value;
68070
68095
  }
@@ -68431,6 +68456,7 @@ var Config = class {
68431
68456
  configIsRoute = null;
68432
68457
  routesDir;
68433
68458
  schemaPollInterval;
68459
+ schemaPollTimeout;
68434
68460
  schemaPollHeaders;
68435
68461
  pluginMode = false;
68436
68462
  plugins = [];
@@ -68500,6 +68526,7 @@ var Config = class {
68500
68526
  this.defaultFragmentMasking = defaultFragmentMasking;
68501
68527
  this.routesDir = join2(this.projectRoot, "src", "routes");
68502
68528
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
68529
+ this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
68503
68530
  this.schemaPollHeaders = watchSchema?.headers ?? {};
68504
68531
  this.rootDir = join2(this.projectRoot, "$houdini");
68505
68532
  this.#fragmentVariableMaps = {};
@@ -69138,7 +69165,11 @@ async function getConfig({
69138
69165
  );
69139
69166
  } else if (!await readFile(_config.schemaPath)) {
69140
69167
  console.log("\u231B Pulling schema from api");
69141
- schemaOk = await pullSchema(apiURL, _config.schemaPath) !== null;
69168
+ schemaOk = await pullSchema(
69169
+ apiURL,
69170
+ _config.schemaPollTimeout,
69171
+ _config.schemaPath
69172
+ ) !== null;
69142
69173
  }
69143
69174
  }
69144
69175
  if (schemaOk && !noSchema) {
@@ -78787,6 +78818,7 @@ function watch_remote_schema(opts = {}) {
78787
78818
  try {
78788
78819
  const schemaState = await pullSchema(
78789
78820
  apiURL,
78821
+ config2.schemaPollTimeout,
78790
78822
  config2.schemaPath ?? path_exports.resolve(process.cwd(), "schema.json"),
78791
78823
  await config2.pullHeaders()
78792
78824
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.2.48",
3
+ "version": "1.2.49",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",