@m1212e/rumble 0.12.18 → 0.12.19

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.
package/out/index.mjs CHANGED
@@ -25,22 +25,26 @@ function generateClient({ apiUrl, rumbleImportPath, useExternalUrqlClient, avail
25
25
  const imports = [];
26
26
  let code = "";
27
27
  if (typeof useExternalUrqlClient === "string") imports.push(`import { urqlClient } from "${useExternalUrqlClient}";`);
28
- else {
29
- imports.push(`import { Client, fetchExchange } from '@urql/core';`);
30
- imports.push(`import { cacheExchange } from '@urql/exchange-graphcache';`);
31
- imports.push(`import { nativeDateExchange } from '${rumbleImportPath}';`);
32
- }
28
+ imports.push(`import { Client, fetchExchange } from '@urql/core';`);
29
+ imports.push(`import { cacheExchange } from '@urql/exchange-graphcache';`);
30
+ imports.push(`import { nativeDateExchange } from '${rumbleImportPath}';`);
33
31
  imports.push(`import { makeLiveQuery, makeMutation, makeSubscription, makeQuery } from '${rumbleImportPath}';`);
34
- if (!useExternalUrqlClient) code += `
35
- const urqlClient = new Client({
32
+ code += `
33
+ export const defaultOptions: ConstructorParameters<Client>[0] = {
36
34
  url: "${apiUrl ?? "PLEASE PROVIDE A URL WHEN GENERATING OR IMPORT AN EXTERNAL URQL CLIENT"}",
37
35
  fetchSubscriptions: true,
38
- exchanges: [cacheExchange({ schema: ${schema ? uneval(minifyIntrospectionQuery(getIntrospectedSchema(schema))) : "undefined"} }), nativeDateExchange, fetchExchange],
36
+ exchanges: [cacheExchange({
37
+ // @ts-ignore
38
+ schema: ${schema ? uneval(minifyIntrospectionQuery(getIntrospectedSchema(schema))) : "undefined"}
39
+ }), nativeDateExchange, fetchExchange],
39
40
  fetchOptions: {
40
41
  credentials: "include",
41
42
  },
42
43
  requestPolicy: "cache-and-network",
43
- });
44
+ }
45
+ `;
46
+ if (!useExternalUrqlClient) code += `
47
+ const urqlClient = new Client(defaultOptions);
44
48
  `;
45
49
  code += `
46
50
  export const client = {