@apollo/client 3.7.4 → 3.7.6

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.
Files changed (227) hide show
  1. package/apollo-client.cjs +120 -61
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/core/cache.d.ts +1 -1
  5. package/cache/core/cache.d.ts.map +1 -1
  6. package/cache/core/cache.js.map +1 -1
  7. package/cache/core/types/common.d.ts +7 -7
  8. package/cache/core/types/common.d.ts.map +1 -1
  9. package/cache/inmemory/entityStore.d.ts +1 -1
  10. package/cache/inmemory/entityStore.d.ts.map +1 -1
  11. package/cache/inmemory/helpers.js.map +1 -1
  12. package/cache/inmemory/inMemoryCache.d.ts +3 -2
  13. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  14. package/cache/inmemory/inMemoryCache.js.map +1 -1
  15. package/cache/inmemory/policies.d.ts +12 -12
  16. package/cache/inmemory/policies.d.ts.map +1 -1
  17. package/cache/inmemory/policies.js.map +1 -1
  18. package/cache/inmemory/reactiveVars.d.ts +1 -1
  19. package/cache/inmemory/reactiveVars.d.ts.map +1 -1
  20. package/cache/inmemory/readFromStore.d.ts +2 -2
  21. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  22. package/cache/inmemory/types.d.ts +4 -4
  23. package/cache/inmemory/types.d.ts.map +1 -1
  24. package/cache/inmemory/writeToStore.d.ts +1 -1
  25. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  26. package/cache/inmemory/writeToStore.js.map +1 -1
  27. package/core/ApolloClient.d.ts +5 -5
  28. package/core/ApolloClient.d.ts.map +1 -1
  29. package/core/ApolloClient.js.map +1 -1
  30. package/core/LocalState.d.ts +9 -6
  31. package/core/LocalState.d.ts.map +1 -1
  32. package/core/LocalState.js +61 -14
  33. package/core/LocalState.js.map +1 -1
  34. package/core/ObservableQuery.d.ts +5 -5
  35. package/core/ObservableQuery.d.ts.map +1 -1
  36. package/core/ObservableQuery.js +1 -1
  37. package/core/ObservableQuery.js.map +1 -1
  38. package/core/QueryInfo.d.ts +1 -1
  39. package/core/QueryInfo.d.ts.map +1 -1
  40. package/core/QueryManager.d.ts +7 -7
  41. package/core/QueryManager.d.ts.map +1 -1
  42. package/core/QueryManager.js +17 -9
  43. package/core/QueryManager.js.map +1 -1
  44. package/core/core.cjs +79 -24
  45. package/core/core.cjs.map +1 -1
  46. package/core/core.cjs.native.js +79 -24
  47. package/core/types.d.ts +18 -17
  48. package/core/types.d.ts.map +1 -1
  49. package/core/types.js +1 -0
  50. package/core/types.js.map +1 -1
  51. package/core/watchQueryOptions.d.ts +11 -11
  52. package/core/watchQueryOptions.d.ts.map +1 -1
  53. package/core/watchQueryOptions.js.map +1 -1
  54. package/errors/index.d.ts +2 -2
  55. package/errors/index.d.ts.map +1 -1
  56. package/invariantErrorCodes.js +48 -43
  57. package/link/batch/batch.cjs +5 -3
  58. package/link/batch/batch.cjs.map +1 -1
  59. package/link/batch/batch.cjs.native.js +5 -3
  60. package/link/batch/batching.d.ts +2 -2
  61. package/link/batch/batching.d.ts.map +1 -1
  62. package/link/batch/batching.js +5 -3
  63. package/link/batch/batching.js.map +1 -1
  64. package/link/context/index.d.ts +2 -1
  65. package/link/context/index.d.ts.map +1 -1
  66. package/link/context/index.js.map +1 -1
  67. package/link/core/ApolloLink.js +1 -1
  68. package/link/core/core.cjs +1 -1
  69. package/link/core/core.cjs.map +1 -1
  70. package/link/core/core.cjs.native.js +1 -1
  71. package/link/core/types.d.ts +11 -10
  72. package/link/core/types.d.ts.map +1 -1
  73. package/link/core/types.js.map +1 -1
  74. package/link/http/checkFetcher.js +1 -1
  75. package/link/http/createHttpLink.d.ts.map +1 -1
  76. package/link/http/createHttpLink.js +1 -0
  77. package/link/http/createHttpLink.js.map +1 -1
  78. package/link/http/http.cjs +6 -3
  79. package/link/http/http.cjs.map +1 -1
  80. package/link/http/http.cjs.native.js +6 -3
  81. package/link/http/iterators/async.js.map +1 -1
  82. package/link/http/iterators/nodeStream.js.map +1 -1
  83. package/link/http/iterators/promise.js.map +1 -1
  84. package/link/http/iterators/reader.js.map +1 -1
  85. package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
  86. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  87. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  88. package/link/http/selectHttpOptionsAndBody.d.ts +2 -2
  89. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  90. package/link/http/selectHttpOptionsAndBody.js +3 -1
  91. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  92. package/link/http/serializeFetchParameter.d.ts +1 -1
  93. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  94. package/link/http/serializeFetchParameter.js +1 -1
  95. package/link/persisted-queries/index.d.ts +2 -2
  96. package/link/persisted-queries/index.d.ts.map +1 -1
  97. package/link/persisted-queries/index.js +2 -2
  98. package/link/persisted-queries/persisted-queries.cjs +2 -2
  99. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  100. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  101. package/link/utils/throwServerError.d.ts +1 -1
  102. package/link/utils/throwServerError.d.ts.map +1 -1
  103. package/link/utils/utils.cjs +1 -1
  104. package/link/utils/utils.cjs.map +1 -1
  105. package/link/utils/utils.cjs.native.js +1 -1
  106. package/link/utils/validateOperation.js +1 -1
  107. package/package.json +15 -15
  108. package/react/components/Query.d.ts +2 -2
  109. package/react/components/Query.d.ts.map +1 -1
  110. package/react/components/Query.js.map +1 -1
  111. package/react/components/Subscription.d.ts +2 -2
  112. package/react/components/Subscription.d.ts.map +1 -1
  113. package/react/components/Subscription.js.map +1 -1
  114. package/react/components/types.d.ts +2 -2
  115. package/react/components/types.d.ts.map +1 -1
  116. package/react/components/types.js.map +1 -1
  117. package/react/context/ApolloConsumer.js +1 -1
  118. package/react/context/ApolloProvider.js +1 -1
  119. package/react/context/context.cjs +2 -2
  120. package/react/context/context.cjs.map +1 -1
  121. package/react/context/context.cjs.native.js +2 -2
  122. package/react/hoc/graphql.d.ts +2 -1
  123. package/react/hoc/graphql.d.ts.map +1 -1
  124. package/react/hoc/graphql.js.map +1 -1
  125. package/react/hoc/hoc-utils.d.ts +1 -1
  126. package/react/hoc/hoc-utils.d.ts.map +1 -1
  127. package/react/hoc/hoc-utils.js +1 -1
  128. package/react/hoc/hoc.cjs +2 -2
  129. package/react/hoc/hoc.cjs.map +1 -1
  130. package/react/hoc/hoc.cjs.native.js +2 -2
  131. package/react/hoc/mutation-hoc.d.ts +2 -2
  132. package/react/hoc/mutation-hoc.d.ts.map +1 -1
  133. package/react/hoc/mutation-hoc.js.map +1 -1
  134. package/react/hoc/query-hoc.d.ts +1 -1
  135. package/react/hoc/query-hoc.d.ts.map +1 -1
  136. package/react/hoc/query-hoc.js.map +1 -1
  137. package/react/hoc/subscription-hoc.d.ts +1 -1
  138. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  139. package/react/hoc/subscription-hoc.js.map +1 -1
  140. package/react/hoc/types.d.ts +6 -6
  141. package/react/hoc/types.d.ts.map +1 -1
  142. package/react/hoc/types.js.map +1 -1
  143. package/react/hoc/withApollo.js +1 -1
  144. package/react/hooks/hooks.cjs +10 -9
  145. package/react/hooks/hooks.cjs.map +1 -1
  146. package/react/hooks/hooks.cjs.native.js +10 -9
  147. package/react/hooks/useApolloClient.js +1 -1
  148. package/react/hooks/useFragment.d.ts +2 -1
  149. package/react/hooks/useFragment.d.ts.map +1 -1
  150. package/react/hooks/useFragment.js +9 -8
  151. package/react/hooks/useFragment.js.map +1 -1
  152. package/react/hooks/useLazyQuery.d.ts +1 -1
  153. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  154. package/react/hooks/useLazyQuery.js.map +1 -1
  155. package/react/hooks/useQuery.d.ts +3 -3
  156. package/react/hooks/useQuery.d.ts.map +1 -1
  157. package/react/hooks/useQuery.js.map +1 -1
  158. package/react/hooks/useSubscription.d.ts +1 -1
  159. package/react/hooks/useSubscription.d.ts.map +1 -1
  160. package/react/hooks/useSubscription.js.map +1 -1
  161. package/react/hooks/useSyncExternalStore.d.ts +1 -1
  162. package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
  163. package/react/parser/index.js +5 -5
  164. package/react/parser/parser.cjs +5 -5
  165. package/react/parser/parser.cjs.map +1 -1
  166. package/react/parser/parser.cjs.native.js +5 -5
  167. package/react/ssr/RenderPromises.d.ts +4 -4
  168. package/react/ssr/RenderPromises.d.ts.map +1 -1
  169. package/react/ssr/RenderPromises.js.map +1 -1
  170. package/react/ssr/getDataFromTree.d.ts +1 -1
  171. package/react/ssr/getDataFromTree.d.ts.map +1 -1
  172. package/react/types/types.d.ts +17 -17
  173. package/react/types/types.d.ts.map +1 -1
  174. package/react/types/types.js.map +1 -1
  175. package/testing/core/core.cjs +1 -1
  176. package/testing/core/core.cjs.map +1 -1
  177. package/testing/core/core.cjs.native.js +1 -1
  178. package/testing/core/mocking/mockFetch.js.map +1 -1
  179. package/testing/core/mocking/mockLink.d.ts +1 -1
  180. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  181. package/testing/core/mocking/mockLink.js +1 -1
  182. package/testing/core/observableToPromise.d.ts +2 -2
  183. package/testing/core/observableToPromise.d.ts.map +1 -1
  184. package/testing/core/observableToPromise.js.map +1 -1
  185. package/utilities/common/cloneDeep.js.map +1 -1
  186. package/utilities/common/errorHandling.d.ts +2 -2
  187. package/utilities/common/errorHandling.d.ts.map +1 -1
  188. package/utilities/common/errorHandling.js.map +1 -1
  189. package/utilities/common/incrementalResult.d.ts +4 -4
  190. package/utilities/common/incrementalResult.d.ts.map +1 -1
  191. package/utilities/common/incrementalResult.js.map +1 -1
  192. package/utilities/common/mergeDeep.d.ts +2 -2
  193. package/utilities/common/mergeDeep.d.ts.map +1 -1
  194. package/utilities/common/mergeOptions.d.ts +2 -2
  195. package/utilities/common/mergeOptions.d.ts.map +1 -1
  196. package/utilities/common/mergeOptions.js.map +1 -1
  197. package/utilities/globals/globals.cjs +1 -1
  198. package/utilities/globals/globals.cjs.map +1 -1
  199. package/utilities/globals/globals.cjs.native.js +1 -1
  200. package/utilities/globals/index.js +1 -1
  201. package/utilities/graphql/directives.d.ts +2 -2
  202. package/utilities/graphql/directives.d.ts.map +1 -1
  203. package/utilities/graphql/directives.js +4 -4
  204. package/utilities/graphql/directives.js.map +1 -1
  205. package/utilities/graphql/fragments.d.ts +1 -1
  206. package/utilities/graphql/fragments.d.ts.map +1 -1
  207. package/utilities/graphql/fragments.js +3 -3
  208. package/utilities/graphql/getFromAST.js +8 -8
  209. package/utilities/graphql/storeUtils.d.ts +3 -3
  210. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  211. package/utilities/graphql/storeUtils.js +1 -1
  212. package/utilities/graphql/storeUtils.js.map +1 -1
  213. package/utilities/graphql/transform.d.ts +9 -9
  214. package/utilities/graphql/transform.d.ts.map +1 -1
  215. package/utilities/graphql/transform.js.map +1 -1
  216. package/utilities/observables/Concast.d.ts +5 -5
  217. package/utilities/observables/Concast.d.ts.map +1 -1
  218. package/utilities/observables/asyncMap.js.map +1 -1
  219. package/utilities/policies/pagination.d.ts +7 -7
  220. package/utilities/policies/pagination.d.ts.map +1 -1
  221. package/utilities/policies/pagination.js.map +1 -1
  222. package/utilities/types/IsStrictlyAny.d.ts +3 -3
  223. package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
  224. package/utilities/utilities.cjs +16 -16
  225. package/utilities/utilities.cjs.map +1 -1
  226. package/utilities/utilities.cjs.native.js +16 -16
  227. package/version.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parseAndCheckHttpResponse.js","sourceRoot":"","sources":["../../../src/link/http/parseAndCheckHttpResponse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGpC,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAQ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C,MAAM,CAAE,CACnE,CAAC;aACH;YACD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBACtB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;gBACpC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EACtC;gBAEA,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,iDACE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;oBACvB,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,aAAa,EAAhB,CAAgB,CAAC;oBAC1C,CAAC,CAAC,UAAU,CAAC,aAAa,OAC1B,CACL,CAAC;aACH;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IA7BJ,CA6BI,CAAC;AACT,CAAC","sourcesContent":["import { responseIterator } from \"./responseIterator\";\nimport { Operation } from \"../core\";\nimport { throwServerError } from \"../utils\";\nimport { Observer } from \"../../utilities\";\n\nconst { hasOwnProperty } = Object.prototype;\n\nexport type ServerParseError = Error & {\n response: Response;\n statusCode: number;\n bodyText: string;\n};\n\nexport async function readMultipartBody<T = Record<string, unknown>>(\n response: Response,\n observer: Observer<T>\n) {\n if (TextDecoder === undefined) {\n throw new Error(\n \"TextDecoder must be defined in the environment: please import a polyfill.\"\n );\n }\n const decoder = new TextDecoder(\"utf-8\");\n const contentType = response.headers?.get('content-type');\n const delimiter = \"boundary=\";\n\n // parse boundary value and ignore any subsequent name/value pairs after ;\n // https://www.rfc-editor.org/rfc/rfc9110.html#name-parameters\n // e.g. multipart/mixed;boundary=\"graphql\";deferSpec=20220824\n // if no boundary is specified, default to -\n const boundaryVal = contentType?.includes(delimiter)\n ? contentType\n ?.substring(contentType?.indexOf(delimiter) + delimiter.length)\n .replace(/['\"]/g, \"\")\n .replace(/\\;(.*)/gm, \"\")\n .trim()\n : \"-\";\n\n let boundary = `--${boundaryVal}`;\n let buffer = \"\";\n const iterator = responseIterator(response);\n let running = true;\n\n while (running) {\n const { value, done } = await iterator.next();\n const chunk = typeof value === \"string\" ? value : decoder.decode(value);\n running = !done;\n buffer += chunk;\n let bi = buffer.indexOf(boundary);\n\n while (bi > -1) {\n let message: string;\n [message, buffer] = [\n buffer.slice(0, bi),\n buffer.slice(bi + boundary.length),\n ];\n if (message.trim()) {\n const i = message.indexOf(\"\\r\\n\\r\\n\");\n const headers = parseHeaders(message.slice(0, i));\n const contentType = headers[\"content-type\"];\n if (\n contentType &&\n contentType.toLowerCase().indexOf(\"application/json\") === -1\n ) {\n throw new Error(\"Unsupported patch content type: application/json is required.\");\n }\n const body = message.slice(i);\n\n try {\n const result = parseJsonBody<T>(response, body.replace(\"\\r\\n\", \"\"));\n if (\n Object.keys(result).length > 1 ||\n \"data\" in result ||\n \"incremental\" in result ||\n \"errors\" in result\n ) {\n // for the last chunk with only `hasNext: false`,\n // we don't need to call observer.next as there is no data/errors\n observer.next?.(result);\n }\n } catch (err) {\n handleError(err, observer);\n }\n }\n bi = buffer.indexOf(boundary);\n }\n }\n observer.complete?.();\n}\n\nexport function parseHeaders(headerText: string): Record<string, string> {\n const headersInit: Record<string, string> = {};\n headerText.split(\"\\n\").forEach((line) => {\n const i = line.indexOf(\":\");\n if (i > -1) {\n // normalize headers to lowercase\n const name = line.slice(0, i).trim().toLowerCase();\n const value = line.slice(i + 1).trim();\n headersInit[name] = value;\n }\n });\n return headersInit;\n}\n\nexport function parseJsonBody<T>(response: Response, bodyText: string): T {\n if (response.status >= 300) {\n // Network error\n const getResult = () => {\n try {\n return JSON.parse(bodyText);\n } catch (err) {\n return bodyText\n }\n }\n throwServerError(\n response,\n getResult(),\n `Response not successful: Received status code ${response.status}`,\n );\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch (err) {\n const parseError = err as ServerParseError;\n parseError.name = \"ServerParseError\";\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n throw parseError;\n }\n}\n\nexport function handleError(err: any, observer: Observer<any>) {\n if (err.name === \"AbortError\") return;\n // if it is a network error, BUT there is graphql result info fire\n // the next observer before calling error this gives apollo-client\n // (and react-apollo) the `graphqlErrors` and `networkErrors` to\n // pass to UI this should only happen if we *also* have data as\n // part of the response key per the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we don't call next, the UI can only show networkError\n // because AC didn't get any graphqlErrors this is graphql\n // execution result info (i.e errors and possibly data) this is\n // because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status\n // of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next?.(err.result);\n }\n\n observer.error?.(err);\n}\n\nexport function readJsonBody<T = Record<string, unknown>>(\n response: Response,\n operation: Operation,\n observer: Observer<T>\n) {\n parseAndCheckHttpResponse(operation)(response)\n .then((result) => {\n observer.next?.(result);\n observer.complete?.();\n })\n .catch((err) => handleError(err, observer));\n}\n\nexport function parseAndCheckHttpResponse(operations: Operation | Operation[]) {\n return (response: Response) =>\n response\n .text()\n .then((bodyText) => parseJsonBody(response, bodyText))\n .then((result: any) => {\n if (response.status >= 300) {\n // Network error\n throwServerError(\n response,\n result,\n `Response not successful: Received status code ${response.status}`\n );\n }\n if (\n !Array.isArray(result) &&\n !hasOwnProperty.call(result, \"data\") &&\n !hasOwnProperty.call(result, \"errors\")\n ) {\n // Data error\n throwServerError(\n response,\n result,\n `Server response was missing for query '${\n Array.isArray(operations)\n ? operations.map((op) => op.operationName)\n : operations.operationName\n }'.`\n );\n }\n return result;\n });\n}\n"]}
1
+ {"version":3,"file":"parseAndCheckHttpResponse.js","sourceRoot":"","sources":["../../../src/link/http/parseAndCheckHttpResponse.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EAAE,QAAQ,CAAC,EAAjC,CAAiC,CAAC;aACrD,IAAI,CAAC,UAAC,MAAW;YAChB,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;gBAE1B,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,wDAAiD,QAAQ,CAAC,MAAM,CAAE,CACnE,CAAC;aACH;YACD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBACtB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;gBACpC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EACtC;gBAEA,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,iDACE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;oBACvB,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,aAAa,EAAhB,CAAgB,CAAC;oBAC1C,CAAC,CAAC,UAAU,CAAC,aAAa,OAC1B,CACL,CAAC;aACH;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IA7BJ,CA6BI,CAAC;AACT,CAAC","sourcesContent":["import { responseIterator } from \"./responseIterator\";\nimport { Operation } from \"../core\";\nimport { throwServerError } from \"../utils\";\nimport { Observer } from \"../../utilities\";\n\nconst { hasOwnProperty } = Object.prototype;\n\nexport type ServerParseError = Error & {\n response: Response;\n statusCode: number;\n bodyText: string;\n};\n\nexport async function readMultipartBody<\n T extends object = Record<string, unknown>\n>(response: Response, observer: Observer<T>) {\n if (TextDecoder === undefined) {\n throw new Error(\n \"TextDecoder must be defined in the environment: please import a polyfill.\"\n );\n }\n const decoder = new TextDecoder(\"utf-8\");\n const contentType = response.headers?.get('content-type');\n const delimiter = \"boundary=\";\n\n // parse boundary value and ignore any subsequent name/value pairs after ;\n // https://www.rfc-editor.org/rfc/rfc9110.html#name-parameters\n // e.g. multipart/mixed;boundary=\"graphql\";deferSpec=20220824\n // if no boundary is specified, default to -\n const boundaryVal = contentType?.includes(delimiter)\n ? contentType\n ?.substring(contentType?.indexOf(delimiter) + delimiter.length)\n .replace(/['\"]/g, \"\")\n .replace(/\\;(.*)/gm, \"\")\n .trim()\n : \"-\";\n\n let boundary = `--${boundaryVal}`;\n let buffer = \"\";\n const iterator = responseIterator(response);\n let running = true;\n\n while (running) {\n const { value, done } = await iterator.next();\n const chunk = typeof value === \"string\" ? value : decoder.decode(value);\n running = !done;\n buffer += chunk;\n let bi = buffer.indexOf(boundary);\n\n while (bi > -1) {\n let message: string;\n [message, buffer] = [\n buffer.slice(0, bi),\n buffer.slice(bi + boundary.length),\n ];\n if (message.trim()) {\n const i = message.indexOf(\"\\r\\n\\r\\n\");\n const headers = parseHeaders(message.slice(0, i));\n const contentType = headers[\"content-type\"];\n if (\n contentType &&\n contentType.toLowerCase().indexOf(\"application/json\") === -1\n ) {\n throw new Error(\"Unsupported patch content type: application/json is required.\");\n }\n const body = message.slice(i);\n\n try {\n const result = parseJsonBody<T>(response, body.replace(\"\\r\\n\", \"\"));\n if (\n Object.keys(result).length > 1 ||\n \"data\" in result ||\n \"incremental\" in result ||\n \"errors\" in result\n ) {\n // for the last chunk with only `hasNext: false`,\n // we don't need to call observer.next as there is no data/errors\n observer.next?.(result);\n }\n } catch (err) {\n handleError(err, observer);\n }\n }\n bi = buffer.indexOf(boundary);\n }\n }\n observer.complete?.();\n}\n\nexport function parseHeaders(headerText: string): Record<string, string> {\n const headersInit: Record<string, string> = {};\n headerText.split(\"\\n\").forEach((line) => {\n const i = line.indexOf(\":\");\n if (i > -1) {\n // normalize headers to lowercase\n const name = line.slice(0, i).trim().toLowerCase();\n const value = line.slice(i + 1).trim();\n headersInit[name] = value;\n }\n });\n return headersInit;\n}\n\nexport function parseJsonBody<T>(response: Response, bodyText: string): T {\n if (response.status >= 300) {\n // Network error\n const getResult = () => {\n try {\n return JSON.parse(bodyText);\n } catch (err) {\n return bodyText\n }\n }\n throwServerError(\n response,\n getResult(),\n `Response not successful: Received status code ${response.status}`,\n );\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch (err) {\n const parseError = err as ServerParseError;\n parseError.name = \"ServerParseError\";\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n throw parseError;\n }\n}\n\nexport function handleError(err: any, observer: Observer<any>) {\n if (err.name === \"AbortError\") return;\n // if it is a network error, BUT there is graphql result info fire\n // the next observer before calling error this gives apollo-client\n // (and react-apollo) the `graphqlErrors` and `networkErrors` to\n // pass to UI this should only happen if we *also* have data as\n // part of the response key per the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we don't call next, the UI can only show networkError\n // because AC didn't get any graphqlErrors this is graphql\n // execution result info (i.e errors and possibly data) this is\n // because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status\n // of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next?.(err.result);\n }\n\n observer.error?.(err);\n}\n\nexport function readJsonBody<T = Record<string, unknown>>(\n response: Response,\n operation: Operation,\n observer: Observer<T>\n) {\n parseAndCheckHttpResponse(operation)(response)\n .then((result) => {\n observer.next?.(result);\n observer.complete?.();\n })\n .catch((err) => handleError(err, observer));\n}\n\nexport function parseAndCheckHttpResponse(operations: Operation | Operation[]) {\n return (response: Response) =>\n response\n .text()\n .then((bodyText) => parseJsonBody(response, bodyText))\n .then((result: any) => {\n if (response.status >= 300) {\n // Network error\n throwServerError(\n response,\n result,\n `Response not successful: Received status code ${response.status}`\n );\n }\n if (\n !Array.isArray(result) &&\n !hasOwnProperty.call(result, \"data\") &&\n !hasOwnProperty.call(result, \"errors\")\n ) {\n // Data error\n throwServerError(\n response,\n result,\n `Server response was missing for query '${\n Array.isArray(operations)\n ? operations.map((op) => op.operationName)\n : operations.operationName\n }'.`\n );\n }\n return result;\n });\n}\n"]}
@@ -16,7 +16,7 @@ export interface HttpOptions {
16
16
  uri?: string | UriFunction;
17
17
  includeExtensions?: boolean;
18
18
  fetch?: WindowOrWorkerGlobalScope['fetch'];
19
- headers?: any;
19
+ headers?: Record<string, string>;
20
20
  preserveHeaderCase?: boolean;
21
21
  credentials?: string;
22
22
  fetchOptions?: any;
@@ -32,7 +32,7 @@ export interface HttpQueryOptions {
32
32
  export interface HttpConfig {
33
33
  http?: HttpQueryOptions;
34
34
  options?: any;
35
- headers?: any;
35
+ headers?: Record<string, string>;
36
36
  credentials?: any;
37
37
  }
38
38
  export declare const fallbackHttpConfig: {
@@ -1 +1 @@
1
- {"version":3,"file":"selectHttpOptionsAndBody.d.ts","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,WAAW,OAAO;IACtB,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,KAAK,GAAG,MAAM,CAAA;CACrD;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,WAAW;IAM1B,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAO3B,iBAAiB,CAAC,EAAE,OAA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AA8BD,eAAO,MAAM,kBAAkB;;;;;;;;;CAI9B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,OAAwC,CAAC;AAEtE,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,UAAU,EAC1B,GAAG,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC;;;EAQ9B;AAED,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,GAAG,OAAO,EAAE,UAAU,EAAE;;;EA0CzB"}
@@ -42,7 +42,9 @@ export function selectHttpOptionsAndBodyInternal(operation, printer) {
42
42
  }
43
43
  http = __assign(__assign({}, http), config.http);
44
44
  });
45
- options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
45
+ if (options.headers) {
46
+ options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
47
+ }
46
48
  var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
47
49
  var body = { operationName: operationName, variables: variables };
48
50
  if (http.includeExtensions)
@@ -1 +1 @@
1
- {"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":";AAAA,OAAO,EAAW,KAAK,EAAE,MAAM,SAAS,CAAC;AAMxC,CAAC;AA4FF,IAAM,kBAAkB,GAAqB;IAC3C,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,IAAM,cAAc,GAAG;IAErB,MAAM,EAAE,KAAK;IAab,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,IAAM,cAAc,GAAG;IACrB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,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AAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import { ASTNode, print } from 'graphql';\n\nimport { Operation } from '../core';\n\nexport interface Printer {\n (node: ASTNode, originalPrint: typeof print): string\n};\n\nexport interface UriFunction {\n (operation: Operation): string;\n}\n\nexport interface Body {\n query?: string;\n operationName?: string;\n variables?: Record<string, any>;\n extensions?: Record<string, any>;\n}\n\nexport interface HttpOptions {\n /**\n * The URI to use when fetching operations.\n *\n * Defaults to '/graphql'.\n */\n uri?: string | UriFunction;\n\n /**\n * Passes the extensions field to your graphql server.\n *\n * Defaults to false.\n */\n includeExtensions?: boolean;\n\n /**\n * A `fetch`-compatible API to use when making requests.\n */\n fetch?: WindowOrWorkerGlobalScope['fetch'];\n\n /**\n * An object representing values to be sent as headers on the request.\n */\n headers?: any;\n\n /**\n * If set to true, header names won't be automatically normalized to \n * lowercase. This allows for non-http-spec-compliant servers that might \n * expect capitalized header names.\n */\n preserveHeaderCase?: boolean;\n\n /**\n * The credentials policy you want to use for the fetch call.\n */\n credentials?: string;\n\n /**\n * Any overrides of the fetch options argument to pass to the fetch call.\n */\n fetchOptions?: any;\n\n /**\n * If set to true, use the HTTP GET method for query operations. Mutations\n * will still use the method specified in fetchOptions.method (which defaults\n * to POST).\n */\n useGETForQueries?: boolean;\n\n /**\n * If set to true, the default behavior of stripping unused variables\n * from the request will be disabled.\n *\n * Unused variables are likely to trigger server-side validation errors,\n * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this\n * includeUnusedVariables option can be useful if your server deviates\n * from the GraphQL specification by not strictly enforcing that rule.\n */\n includeUnusedVariables?: boolean;\n /**\n * A function to substitute for the default query print function. Can be\n * used to apply changes to the results of the print function.\n */\n print?: Printer;\n}\n\nexport interface HttpQueryOptions {\n includeQuery?: boolean;\n includeExtensions?: boolean;\n preserveHeaderCase?: boolean;\n}\n\nexport interface HttpConfig {\n http?: HttpQueryOptions;\n options?: any;\n headers?: any;\n credentials?: any;\n}\n\nconst defaultHttpOptions: HttpQueryOptions = {\n includeQuery: true,\n includeExtensions: false,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: '*/*',\n // The content-type header describes the type of the body of the request, and\n // so it typically only is sent with requests that actually have bodies. One\n // could imagine that Apollo Client would remove this header when constructing\n // a GET request (which has no body), but we historically have not done that.\n // This means that browsers will preflight all Apollo Client requests (even\n // GET requests). Apollo Server's CSRF prevention feature (introduced in\n // AS3.7) takes advantage of this fact and does not block requests with this\n // header. If you want to drop this header from GET requests, then you should\n // probably replace it with a `apollo-require-preflight` header, or servers\n // with CSRF prevention enabled might block your GET request. See\n // https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf\n // for more details.\n 'content-type': 'application/json',\n};\n\nconst defaultOptions = {\n method: 'POST',\n};\n\nexport const fallbackHttpConfig = {\n http: defaultHttpOptions,\n headers: defaultHeaders,\n options: defaultOptions,\n};\n\nexport const defaultPrinter: Printer = (ast, printer) => printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: Operation,\n fallbackConfig: HttpConfig,\n ...configs: Array<HttpConfig>\n) {\n configs.unshift(fallbackConfig);\n return selectHttpOptionsAndBodyInternal(\n operation,\n defaultPrinter,\n ...configs,\n );\n}\n\nexport function selectHttpOptionsAndBodyInternal(\n operation: Operation,\n printer: Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as HttpQueryOptions;\n\n configs.forEach(config => {\n options = {\n ...options,\n ...config.options,\n headers: {\n ...options.headers,\n ...config.headers,\n }\n };\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: Body = { operationName, variables };\n\n if (http.includeExtensions) (body as any).extensions = extensions;\n\n // not sending the query (i.e persisted queries)\n if (http.includeQuery) (body as any).query = printer(query, print);\n\n return {\n options,\n body,\n };\n};\n\n// Remove potential duplicate header names, preserving last (by insertion order).\n// This is done to prevent unintentionally duplicating a header instead of \n// overwriting it (See #8447 and #8449).\nfunction removeDuplicateHeaders(\n headers: Record<string, string>,\n preserveHeaderCase: boolean | undefined\n): typeof headers {\n\n // If we're not preserving the case, just remove duplicates w/ normalization.\n if (!preserveHeaderCase) {\n const normalizedHeaders = Object.create(null);\n Object.keys(Object(headers)).forEach(name => {\n normalizedHeaders[name.toLowerCase()] = headers[name];\n });\n return normalizedHeaders; \n }\n\n // If we are preserving the case, remove duplicates w/ normalization,\n // preserving the original name.\n // This allows for non-http-spec-compliant servers that expect intentionally \n // capitalized header names (See #6741).\n const headerData = Object.create(null);\n Object.keys(Object(headers)).forEach(name => {\n headerData[name.toLowerCase()] = { originalName: name, value: headers[name] }\n });\n\n const normalizedHeaders = Object.create(null);\n Object.keys(headerData).forEach(name => {\n normalizedHeaders[headerData[name].originalName] = headerData[name].value;\n });\n return normalizedHeaders;\n}\n"]}
1
+ {"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":";AAAA,OAAO,EAAW,KAAK,EAAE,MAAM,SAAS,CAAC;AAMxC,CAAC;AA4FF,IAAM,kBAAkB,GAAqB;IAC3C,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,IAAM,cAAc,GAAG;IAErB,MAAM,EAAE,KAAK;IAab,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,IAAM,cAAc,GAAG;IACrB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc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CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import { ASTNode, print } from 'graphql';\n\nimport { Operation } from '../core';\n\nexport interface Printer {\n (node: ASTNode, originalPrint: typeof print): string\n};\n\nexport interface UriFunction {\n (operation: Operation): string;\n}\n\nexport interface Body {\n query?: string;\n operationName?: string;\n variables?: Record<string, any>;\n extensions?: Record<string, any>;\n}\n\nexport interface HttpOptions {\n /**\n * The URI to use when fetching operations.\n *\n * Defaults to '/graphql'.\n */\n uri?: string | UriFunction;\n\n /**\n * Passes the extensions field to your graphql server.\n *\n * Defaults to false.\n */\n includeExtensions?: boolean;\n\n /**\n * A `fetch`-compatible API to use when making requests.\n */\n fetch?: WindowOrWorkerGlobalScope['fetch'];\n\n /**\n * An object representing values to be sent as headers on the request.\n */\n headers?: Record<string, string>;\n\n /**\n * If set to true, header names won't be automatically normalized to\n * lowercase. This allows for non-http-spec-compliant servers that might\n * expect capitalized header names.\n */\n preserveHeaderCase?: boolean;\n\n /**\n * The credentials policy you want to use for the fetch call.\n */\n credentials?: string;\n\n /**\n * Any overrides of the fetch options argument to pass to the fetch call.\n */\n fetchOptions?: any;\n\n /**\n * If set to true, use the HTTP GET method for query operations. Mutations\n * will still use the method specified in fetchOptions.method (which defaults\n * to POST).\n */\n useGETForQueries?: boolean;\n\n /**\n * If set to true, the default behavior of stripping unused variables\n * from the request will be disabled.\n *\n * Unused variables are likely to trigger server-side validation errors,\n * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this\n * includeUnusedVariables option can be useful if your server deviates\n * from the GraphQL specification by not strictly enforcing that rule.\n */\n includeUnusedVariables?: boolean;\n /**\n * A function to substitute for the default query print function. Can be\n * used to apply changes to the results of the print function.\n */\n print?: Printer;\n}\n\nexport interface HttpQueryOptions {\n includeQuery?: boolean;\n includeExtensions?: boolean;\n preserveHeaderCase?: boolean;\n}\n\nexport interface HttpConfig {\n http?: HttpQueryOptions;\n options?: any;\n headers?: Record<string, string>;\n credentials?: any;\n}\n\nconst defaultHttpOptions: HttpQueryOptions = {\n includeQuery: true,\n includeExtensions: false,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: '*/*',\n // The content-type header describes the type of the body of the request, and\n // so it typically only is sent with requests that actually have bodies. One\n // could imagine that Apollo Client would remove this header when constructing\n // a GET request (which has no body), but we historically have not done that.\n // This means that browsers will preflight all Apollo Client requests (even\n // GET requests). Apollo Server's CSRF prevention feature (introduced in\n // AS3.7) takes advantage of this fact and does not block requests with this\n // header. If you want to drop this header from GET requests, then you should\n // probably replace it with a `apollo-require-preflight` header, or servers\n // with CSRF prevention enabled might block your GET request. See\n // https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf\n // for more details.\n 'content-type': 'application/json',\n};\n\nconst defaultOptions = {\n method: 'POST',\n};\n\nexport const fallbackHttpConfig = {\n http: defaultHttpOptions,\n headers: defaultHeaders,\n options: defaultOptions,\n};\n\nexport const defaultPrinter: Printer = (ast, printer) => printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: Operation,\n fallbackConfig: HttpConfig,\n ...configs: Array<HttpConfig>\n) {\n configs.unshift(fallbackConfig);\n return selectHttpOptionsAndBodyInternal(\n operation,\n defaultPrinter,\n ...configs,\n );\n}\n\nexport function selectHttpOptionsAndBodyInternal(\n operation: Operation,\n printer: Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as HttpQueryOptions;\n\n configs.forEach(config => {\n options = {\n ...options,\n ...config.options,\n headers: {\n ...options.headers,\n ...config.headers,\n }\n };\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n if (options.headers) {\n options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);\n }\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: Body = { operationName, variables };\n\n if (http.includeExtensions) (body as any).extensions = extensions;\n\n // not sending the query (i.e persisted queries)\n if (http.includeQuery) (body as any).query = printer(query, print);\n\n return {\n options,\n body,\n };\n};\n\n// Remove potential duplicate header names, preserving last (by insertion order).\n// This is done to prevent unintentionally duplicating a header instead of\n// overwriting it (See #8447 and #8449).\nfunction removeDuplicateHeaders(\n headers: Record<string, string>,\n preserveHeaderCase: boolean | undefined\n): typeof headers {\n\n // If we're not preserving the case, just remove duplicates w/ normalization.\n if (!preserveHeaderCase) {\n const normalizedHeaders = Object.create(null);\n Object.keys(Object(headers)).forEach(name => {\n normalizedHeaders[name.toLowerCase()] = headers[name];\n });\n return normalizedHeaders;\n }\n\n // If we are preserving the case, remove duplicates w/ normalization,\n // preserving the original name.\n // This allows for non-http-spec-compliant servers that expect intentionally\n // capitalized header names (See #6741).\n const headerData = Object.create(null);\n Object.keys(Object(headers)).forEach(name => {\n headerData[name.toLowerCase()] = { originalName: name, value: headers[name] }\n });\n\n const normalizedHeaders = Object.create(null);\n Object.keys(headerData).forEach(name => {\n normalizedHeaders[headerData[name].originalName] = headerData[name].value;\n });\n return normalizedHeaders;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { InvariantError } from '../../utilities/globals';
2
- export declare type ClientParseError = InvariantError & {
2
+ export type ClientParseError = InvariantError & {
3
3
  parseError: Error;
4
4
  };
5
5
  export declare const serializeFetchParameter: (p: any, label: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"serializeFetchParameter.d.ts","sourceRoot":"","sources":["../../../src/link/http/serializeFetchParameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,oBAAY,gBAAgB,GAAG,cAAc,GAAG;IAC9C,UAAU,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,uBAAuB,MAAO,GAAG,SAAS,MAAM,WAY5D,CAAC"}
1
+ {"version":3,"file":"serializeFetchParameter.d.ts","sourceRoot":"","sources":["../../../src/link/http/serializeFetchParameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAC9C,UAAU,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,uBAAuB,MAAO,GAAG,SAAS,MAAM,WAY5D,CAAC"}
@@ -5,7 +5,7 @@ export var serializeFetchParameter = function (p, label) {
5
5
  serialized = JSON.stringify(p);
6
6
  }
7
7
  catch (e) {
8
- var parseError = __DEV__ ? new InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new InvariantError(23);
8
+ var parseError = __DEV__ ? new InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new InvariantError(24);
9
9
  parseError.parseError = e;
10
10
  throw parseError;
11
11
  }
@@ -8,8 +8,8 @@ export interface ErrorResponse {
8
8
  response?: ExecutionResult;
9
9
  operation: Operation;
10
10
  }
11
- declare type SHA256Function = (...args: any[]) => string | PromiseLike<string>;
12
- declare type GenerateHashFunction = (document: DocumentNode) => string | PromiseLike<string>;
11
+ type SHA256Function = (...args: any[]) => string | PromiseLike<string>;
12
+ type GenerateHashFunction = (document: DocumentNode) => string | PromiseLike<string>;
13
13
  export declare namespace PersistedQueryLink {
14
14
  interface BaseOptions {
15
15
  disable?: (error: ErrorResponse) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/persisted-queries/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQhD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,eAAO,MAAM,OAAO,IAAI,CAAC;AAEzB,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE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C5B,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,KAAK,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AACvE,KAAK,oBAAoB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAErF,yBAAiB,kBAAkB,CAAC;IAClC,UAAU,WAAW;QACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;QAC5C,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;IAED,UAAU,aAAc,SAAQ,WAAW;QACzC,MAAM,EAAE,cAAc,CAAC;QACvB,YAAY,CAAC,EAAE,KAAK,CAAC;KACtB;IAED,UAAU,mBAAoB,SAAQ,WAAW;QAC/C,MAAM,CAAC,EAAE,KAAK,CAAC;QACf,YAAY,EAAE,oBAAoB,CAAC;KACpC;IAED,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,mBAAmB,CAAC;;CAC3D;AAuDD,eAAO,MAAM,wBAAwB,YAC1B,mBAAmB,OAAO,eA4LpC,CAAC"}
@@ -48,7 +48,7 @@ export var createPersistedQueryLink = function (options) {
48
48
  typeof options.generateHash === 'function'), 'Missing/invalid "sha256" or "generateHash" function. Please ' +
49
49
  'configure one using the "createPersistedQueryLink(options)" options ' +
50
50
  'parameter.') : invariant(options && (typeof options.sha256 === 'function' ||
51
- typeof options.generateHash === 'function'), 24);
51
+ typeof options.generateHash === 'function'), 25);
52
52
  var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
53
53
  return Promise.resolve(sha256(print(query)));
54
54
  } : _b, disable = _a.disable, useGETForHashedQueries = _a.useGETForHashedQueries;
@@ -69,7 +69,7 @@ export var createPersistedQueryLink = function (options) {
69
69
  : hashes[hashesChildKey] = getHashPromise(query);
70
70
  }
71
71
  return new ApolloLink(function (operation, forward) {
72
- __DEV__ ? invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : invariant(forward, 25);
72
+ __DEV__ ? invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : invariant(forward, 26);
73
73
  var query = operation.query;
74
74
  return new Observable(function (observer) {
75
75
  var subscription;
@@ -50,7 +50,7 @@ var createPersistedQueryLink = function (options) {
50
50
  typeof options.generateHash === 'function'), 'Missing/invalid "sha256" or "generateHash" function. Please ' +
51
51
  'configure one using the "createPersistedQueryLink(options)" options ' +
52
52
  'parameter.') : globals.invariant(options && (typeof options.sha256 === 'function' ||
53
- typeof options.generateHash === 'function'), 24);
53
+ typeof options.generateHash === 'function'), 25);
54
54
  var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
55
55
  return Promise.resolve(sha256(graphql.print(query)));
56
56
  } : _b, disable = _a.disable, useGETForHashedQueries = _a.useGETForHashedQueries;
@@ -71,7 +71,7 @@ var createPersistedQueryLink = function (options) {
71
71
  : hashes[hashesChildKey] = getHashPromise(query);
72
72
  }
73
73
  return new core.ApolloLink(function (operation, forward) {
74
- __DEV__ ? globals.invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : globals.invariant(forward, 25);
74
+ __DEV__ ? globals.invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : globals.invariant(forward, 26);
75
75
  var query = operation.query;
76
76
  return new utilities.Observable(function (observer) {
77
77
  var subscription;
@@ -1 +1 @@
1
- {"version":3,"file":"persisted-queries.cjs","sources":["index.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { invariant } from '../../utilities/globals';\nimport { print } from 'graphql';\nimport { ApolloLink } from '../core';\nimport { Observable, compact, isNonEmptyArray, } from '../../utilities';\nexport var VERSION = 1;\nexport var PersistedQueryLink;\n(function (PersistedQueryLink) {\n ;\n ;\n ;\n})(PersistedQueryLink || (PersistedQueryLink = {}));\nfunction collectErrorsByMessage(graphQLErrors) {\n var collected = Object.create(null);\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach(function (error) { return collected[error.message] = error; });\n }\n return collected;\n}\nvar defaultOptions = {\n disable: function (_a) {\n var graphQLErrors = _a.graphQLErrors, operation = _a.operation;\n var errorMessages = collectErrorsByMessage(graphQLErrors);\n if (errorMessages.PersistedQueryNotSupported) {\n return true;\n }\n if (errorMessages.PersistedQueryNotFound) {\n return false;\n }\n var response = operation.getContext().response;\n if (response &&\n response.status &&\n (response.status === 400 || response.status === 500)) {\n return true;\n }\n return false;\n },\n useGETForHashedQueries: false,\n};\nfunction operationDefinesMutation(operation) {\n return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });\n}\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar hashesByQuery = new WeakMap();\nvar nextHashesChildKey = 0;\nexport var createPersistedQueryLink = function (options) {\n __DEV__ ? invariant(options && (typeof options.sha256 === 'function' ||\n typeof options.generateHash === 'function'), 'Missing/invalid \"sha256\" or \"generateHash\" function. Please ' +\n 'configure one using the \"createPersistedQueryLink(options)\" options ' +\n 'parameter.') : invariant(options && (typeof options.sha256 === 'function' ||\n typeof options.generateHash === 'function'), 24);\n var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {\n return Promise.resolve(sha256(print(query)));\n } : _b, disable = _a.disable, useGETForHashedQueries = _a.useGETForHashedQueries;\n var supportsPersistedQueries = true;\n var hashesChildKey = 'forLink' + nextHashesChildKey++;\n var getHashPromise = function (query) {\n return new Promise(function (resolve) { return resolve(generateHash(query)); });\n };\n function getQueryHash(query) {\n if (!query || typeof query !== 'object') {\n return getHashPromise(query);\n }\n var hashes = hashesByQuery.get(query);\n if (!hashes)\n hashesByQuery.set(query, hashes = Object.create(null));\n return hasOwnProperty.call(hashes, hashesChildKey)\n ? hashes[hashesChildKey]\n : hashes[hashesChildKey] = getHashPromise(query);\n }\n return new ApolloLink(function (operation, forward) {\n __DEV__ ? invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : invariant(forward, 25);\n var query = operation.query;\n return new Observable(function (observer) {\n var subscription;\n var retried = false;\n var originalFetchOptions;\n var setFetchOptions = false;\n var retry = function (_a, cb) {\n var response = _a.response, networkError = _a.networkError;\n if (!retried && ((response && response.errors) || networkError)) {\n retried = true;\n var graphQLErrors = [];\n var responseErrors = response && response.errors;\n if (isNonEmptyArray(responseErrors)) {\n graphQLErrors.push.apply(graphQLErrors, responseErrors);\n }\n var networkErrors = networkError &&\n networkError.result &&\n networkError.result.errors;\n if (isNonEmptyArray(networkErrors)) {\n graphQLErrors.push.apply(graphQLErrors, networkErrors);\n }\n var disablePayload = {\n response: response,\n networkError: networkError,\n operation: operation,\n graphQLErrors: isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,\n };\n supportsPersistedQueries = !disable(disablePayload);\n if (collectErrorsByMessage(graphQLErrors).PersistedQueryNotFound ||\n !supportsPersistedQueries) {\n if (subscription)\n subscription.unsubscribe();\n operation.setContext({\n http: {\n includeQuery: true,\n includeExtensions: supportsPersistedQueries,\n },\n fetchOptions: {\n method: 'POST',\n },\n });\n if (setFetchOptions) {\n operation.setContext({ fetchOptions: originalFetchOptions });\n }\n subscription = forward(operation).subscribe(handler);\n return;\n }\n }\n cb();\n };\n var handler = {\n next: function (response) {\n retry({ response: response }, function () { return observer.next(response); });\n },\n error: function (networkError) {\n retry({ networkError: networkError }, function () { return observer.error(networkError); });\n },\n complete: observer.complete.bind(observer),\n };\n operation.setContext({\n http: {\n includeQuery: !supportsPersistedQueries,\n includeExtensions: supportsPersistedQueries,\n },\n });\n if (useGETForHashedQueries &&\n supportsPersistedQueries &&\n !operationDefinesMutation(operation)) {\n operation.setContext(function (_a) {\n var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;\n originalFetchOptions = fetchOptions;\n return {\n fetchOptions: __assign(__assign({}, fetchOptions), { method: 'GET' }),\n };\n });\n setFetchOptions = true;\n }\n if (supportsPersistedQueries) {\n getQueryHash(query).then(function (sha256Hash) {\n operation.extensions.persistedQuery = {\n version: VERSION,\n sha256Hash: sha256Hash,\n };\n subscription = forward(operation).subscribe(handler);\n }).catch(observer.error.bind(observer));\n ;\n }\n else {\n subscription = forward(operation).subscribe(handler);\n }\n return function () {\n if (subscription)\n subscription.unsubscribe();\n };\n });\n });\n};\n//# sourceMappingURL=index.js.map"],"names":["PersistedQueryLink","isNonEmptyArray","invariant","compact","print","ApolloLink","Observable","__assign"],"mappings":";;;;;;;;;;AAKU,IAAC,OAAO,GAAG,EAAE;AACZA,oCAAmB;AAC9B,CAAC,UAAU,kBAAkB,EAAE;AAI/B,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC,CAAC;AACpD,SAAS,sBAAsB,CAAC,aAAa,EAAE;AAC/C,IAAI,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACxC,IAAI,IAAIC,yBAAe,CAAC,aAAa,CAAC,EAAE;AACxC,QAAQ,aAAa,CAAC,OAAO,CAAC,UAAU,KAAK,EAAE,EAAE,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC;AACD,IAAI,cAAc,GAAG;AACrB,IAAI,OAAO,EAAE,UAAU,EAAE,EAAE;AAC3B,QAAQ,IAAI,aAAa,GAAG,EAAE,CAAC,aAAa,EAAE,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC;AACvE,QAAQ,IAAI,aAAa,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAClE,QAAQ,IAAI,aAAa,CAAC,0BAA0B,EAAE;AACtD,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS;AACT,QAAQ,IAAI,aAAa,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AAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,UAAU,EAAE;AAC/D,oBAAoB,SAAS,CAAC,UAAU,CAAC,cAAc,GAAG;AAC1D,wBAAwB,OAAO,EAAE,OAAO;AACxC,wBAAwB,UAAU,EAAE,UAAU;AAC9C,qBAAqB,CAAC;AACtB,oBAAoB,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzE,iBAAiB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAExD,aAAa;AACb,iBAAiB;AACjB,gBAAgB,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACrE,aAAa;AACb,YAAY,OAAO,YAAY;AAC/B,gBAAgB,IAAI,YAAY;AAChC,oBAAoB,YAAY,CAAC,WAAW,EAAE,CAAC;AAC/C,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;;;;"}
1
+ {"version":3,"file":"persisted-queries.cjs","sources":["index.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { invariant } from '../../utilities/globals';\nimport { print } from 'graphql';\nimport { ApolloLink } from '../core';\nimport { Observable, compact, isNonEmptyArray, } from '../../utilities';\nexport var VERSION = 1;\nexport var PersistedQueryLink;\n(function (PersistedQueryLink) {\n ;\n ;\n ;\n})(PersistedQueryLink || (PersistedQueryLink = {}));\nfunction collectErrorsByMessage(graphQLErrors) {\n var collected = Object.create(null);\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach(function (error) { return collected[error.message] = error; });\n }\n return collected;\n}\nvar defaultOptions = {\n disable: function (_a) {\n var graphQLErrors = _a.graphQLErrors, operation = _a.operation;\n var errorMessages = collectErrorsByMessage(graphQLErrors);\n if (errorMessages.PersistedQueryNotSupported) {\n return true;\n }\n if (errorMessages.PersistedQueryNotFound) {\n return false;\n }\n var response = operation.getContext().response;\n if (response &&\n response.status &&\n (response.status === 400 || response.status === 500)) {\n return true;\n }\n return false;\n },\n useGETForHashedQueries: false,\n};\nfunction operationDefinesMutation(operation) {\n return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });\n}\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar hashesByQuery = new WeakMap();\nvar nextHashesChildKey = 0;\nexport var createPersistedQueryLink = function (options) {\n __DEV__ ? invariant(options && (typeof options.sha256 === 'function' ||\n typeof options.generateHash === 'function'), 'Missing/invalid \"sha256\" or \"generateHash\" function. Please ' +\n 'configure one using the \"createPersistedQueryLink(options)\" options ' +\n 'parameter.') : invariant(options && (typeof options.sha256 === 'function' ||\n typeof options.generateHash === 'function'), 25);\n var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {\n return Promise.resolve(sha256(print(query)));\n } : _b, disable = _a.disable, useGETForHashedQueries = _a.useGETForHashedQueries;\n var supportsPersistedQueries = true;\n var hashesChildKey = 'forLink' + nextHashesChildKey++;\n var getHashPromise = function (query) {\n return new Promise(function (resolve) { return resolve(generateHash(query)); });\n };\n function getQueryHash(query) {\n if (!query || typeof query !== 'object') {\n return getHashPromise(query);\n }\n var hashes = hashesByQuery.get(query);\n if (!hashes)\n hashesByQuery.set(query, hashes = Object.create(null));\n return hasOwnProperty.call(hashes, hashesChildKey)\n ? hashes[hashesChildKey]\n : hashes[hashesChildKey] = getHashPromise(query);\n }\n return new ApolloLink(function (operation, forward) {\n __DEV__ ? invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : invariant(forward, 26);\n var query = operation.query;\n return new Observable(function (observer) {\n var subscription;\n var retried = false;\n var originalFetchOptions;\n var setFetchOptions = false;\n var retry = function (_a, cb) {\n var response = _a.response, networkError = _a.networkError;\n if (!retried && ((response && response.errors) || networkError)) {\n retried = true;\n var graphQLErrors = [];\n var responseErrors = response && response.errors;\n if (isNonEmptyArray(responseErrors)) {\n graphQLErrors.push.apply(graphQLErrors, responseErrors);\n }\n var networkErrors = networkError &&\n networkError.result &&\n networkError.result.errors;\n if (isNonEmptyArray(networkErrors)) {\n graphQLErrors.push.apply(graphQLErrors, networkErrors);\n }\n var disablePayload = {\n response: response,\n networkError: networkError,\n operation: operation,\n graphQLErrors: isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,\n };\n supportsPersistedQueries = !disable(disablePayload);\n if (collectErrorsByMessage(graphQLErrors).PersistedQueryNotFound ||\n !supportsPersistedQueries) {\n if (subscription)\n subscription.unsubscribe();\n operation.setContext({\n http: {\n includeQuery: true,\n includeExtensions: supportsPersistedQueries,\n },\n fetchOptions: {\n method: 'POST',\n },\n });\n if (setFetchOptions) {\n operation.setContext({ fetchOptions: originalFetchOptions });\n }\n subscription = forward(operation).subscribe(handler);\n return;\n }\n }\n cb();\n };\n var handler = {\n next: function (response) {\n retry({ response: response }, function () { return observer.next(response); });\n },\n error: function (networkError) {\n retry({ networkError: networkError }, function () { return observer.error(networkError); });\n },\n complete: observer.complete.bind(observer),\n };\n operation.setContext({\n http: {\n includeQuery: !supportsPersistedQueries,\n includeExtensions: supportsPersistedQueries,\n },\n });\n if (useGETForHashedQueries &&\n supportsPersistedQueries &&\n !operationDefinesMutation(operation)) {\n operation.setContext(function (_a) {\n var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;\n originalFetchOptions = fetchOptions;\n return {\n fetchOptions: __assign(__assign({}, fetchOptions), { method: 'GET' }),\n };\n });\n setFetchOptions = true;\n }\n if (supportsPersistedQueries) {\n getQueryHash(query).then(function (sha256Hash) {\n operation.extensions.persistedQuery = {\n version: VERSION,\n sha256Hash: sha256Hash,\n };\n subscription = forward(operation).subscribe(handler);\n }).catch(observer.error.bind(observer));\n ;\n }\n else {\n subscription = forward(operation).subscribe(handler);\n }\n return function () {\n if (subscription)\n subscription.unsubscribe();\n };\n });\n });\n};\n//# sourceMapping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AAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAExD,aAAa;AACb,iBAAiB;AACjB,gBAAgB,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACrE,aAAa;AACb,YAAY,OAAO,YAAY;AAC/B,gBAAgB,IAAI,YAAY;AAChC,oBAAoB,YAAY,CAAC,WAAW,EAAE,CAAC;AAC/C,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;;;;"}
@@ -50,7 +50,7 @@ var createPersistedQueryLink = function (options) {
50
50
  typeof options.generateHash === 'function'), 'Missing/invalid "sha256" or "generateHash" function. Please ' +
51
51
  'configure one using the "createPersistedQueryLink(options)" options ' +
52
52
  'parameter.') : globals.invariant(options && (typeof options.sha256 === 'function' ||
53
- typeof options.generateHash === 'function'), 24);
53
+ typeof options.generateHash === 'function'), 25);
54
54
  var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
55
55
  return Promise.resolve(sha256(graphql.print(query)));
56
56
  } : _b, disable = _a.disable, useGETForHashedQueries = _a.useGETForHashedQueries;
@@ -71,7 +71,7 @@ var createPersistedQueryLink = function (options) {
71
71
  : hashes[hashesChildKey] = getHashPromise(query);
72
72
  }
73
73
  return new core.ApolloLink(function (operation, forward) {
74
- __DEV__ ? globals.invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : globals.invariant(forward, 25);
74
+ __DEV__ ? globals.invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : globals.invariant(forward, 26);
75
75
  var query = operation.query;
76
76
  return new utilities.Observable(function (observer) {
77
77
  var subscription;
@@ -1,4 +1,4 @@
1
- export declare type ServerError = Error & {
1
+ export type ServerError = Error & {
2
2
  response: Response;
3
3
  result: Record<string, any>;
4
4
  statusCode: number;
@@ -1 +1 @@
1
- {"version":3,"file":"throwServerError.d.ts","sourceRoot":"","sources":["../../../src/link/utils/throwServerError.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,GAAG,KAAK,GAAG;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,gBAAgB,aACjB,QAAQ,UACV,GAAG,WACF,MAAM,UAQhB,CAAC"}
1
+ {"version":3,"file":"throwServerError.d.ts","sourceRoot":"","sources":["../../../src/link/utils/throwServerError.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,gBAAgB,aACjB,QAAQ,UACV,GAAG,WACF,MAAM,UAQhB,CAAC"}
@@ -61,7 +61,7 @@ function validateOperation(operation) {
61
61
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
62
62
  var key = _a[_i];
63
63
  if (OPERATION_FIELDS.indexOf(key) < 0) {
64
- throw __DEV__ ? new globals.InvariantError("illegal argument: ".concat(key)) : new globals.InvariantError(26);
64
+ throw __DEV__ ? new globals.InvariantError("illegal argument: ".concat(key)) : new globals.InvariantError(27);
65
65
  }
66
66
  }
67
67
  return operation;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["fromError.js","toPromise.js","fromPromise.js","throwServerError.js","validateOperation.js","createOperation.js","transformOperation.js"],"sourcesContent":["import { Observable } from '../../utilities';\nexport function fromError(errorValue) {\n return new Observable(function (observer) {\n observer.error(errorValue);\n });\n}\n//# sourceMappingURL=fromError.js.map","import { invariant } from '../../utilities/globals';\nexport function toPromise(observable) {\n var completed = false;\n return new Promise(function (resolve, reject) {\n observable.subscribe({\n next: function (data) {\n if (completed) {\n __DEV__ && invariant.warn(\"Promise Wrapper does not support multiple results from Observable\");\n }\n else {\n completed = true;\n resolve(data);\n }\n },\n error: reject,\n });\n });\n}\n//# sourceMappingURL=toPromise.js.map","import { Observable } from '../../utilities';\nexport function fromPromise(promise) {\n return new Observable(function (observer) {\n promise\n .then(function (value) {\n observer.next(value);\n observer.complete();\n })\n .catch(observer.error.bind(observer));\n });\n}\n//# sourceMappingURL=fromPromise.js.map","export var throwServerError = function (response, result, message) {\n var error = new Error(message);\n error.name = 'ServerError';\n error.response = response;\n error.statusCode = response.status;\n error.result = result;\n throw error;\n};\n//# sourceMappingURL=throwServerError.js.map","import { InvariantError } from '../../utilities/globals';\nexport function validateOperation(operation) {\n var OPERATION_FIELDS = [\n 'query',\n 'operationName',\n 'variables',\n 'extensions',\n 'context',\n ];\n for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {\n var key = _a[_i];\n if (OPERATION_FIELDS.indexOf(key) < 0) {\n throw __DEV__ ? new InvariantError(\"illegal argument: \".concat(key)) : new InvariantError(26);\n }\n }\n return operation;\n}\n//# sourceMappingURL=validateOperation.js.map","import { __assign } from \"tslib\";\nexport function createOperation(starting, operation) {\n var context = __assign({}, starting);\n var setContext = function (next) {\n if (typeof next === 'function') {\n context = __assign(__assign({}, context), next(context));\n }\n else {\n context = __assign(__assign({}, context), next);\n }\n };\n var getContext = function () { return (__assign({}, context)); };\n Object.defineProperty(operation, 'setContext', {\n enumerable: false,\n value: setContext,\n });\n Object.defineProperty(operation, 'getContext', {\n enumerable: false,\n value: getContext,\n });\n return operation;\n}\n//# sourceMappingURL=createOperation.js.map","import { getOperationName } from '../../utilities';\nexport function transformOperation(operation) {\n var transformedOperation = {\n variables: operation.variables || {},\n extensions: operation.extensions || {},\n operationName: operation.operationName,\n query: operation.query,\n };\n if (!transformedOperation.operationName) {\n transformedOperation.operationName =\n typeof transformedOperation.query !== 'string'\n ? getOperationName(transformedOperation.query) || undefined\n : '';\n }\n return transformedOperation;\n}\n//# sourceMappingURL=transformOperation.js.map"],"names":["Observable","invariant","InvariantError","__assign","getOperationName"],"mappings":";;;;;;;;AACO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,OAAO,IAAIA,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACnC,KAAK,CAAC,CAAC;AACP;;ACJO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC;AAC1B,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM,EAAE;AAClD,QAAQ,UAAU,CAAC,SAAS,CAAC;AAC7B,YAAY,IAAI,EAAE,UAAU,IAAI,EAAE;AAClC,gBAAgB,IAAI,SAAS,EAAE;AAC/B,oBAAoB,OAAO,IAAIC,iBAAS,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;AACnH,iBAAiB;AACjB,qBAAqB;AACrB,oBAAoB,SAAS,GAAG,IAAI,CAAC;AACrC,oBAAoB,OAAO,CAAC,IAAI,CAAC,CAAC;AAClC,iBAAiB;AACjB,aAAa;AACb,YAAY,KAAK,EAAE,MAAM;AACzB,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;AChBO,SAAS,WAAW,CAAC,OAAO,EAAE;AACrC,IAAI,OAAO,IAAID,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,OAAO;AACf,aAAa,IAAI,CAAC,UAAU,KAAK,EAAE;AACnC,YAAY,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,YAAY,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAChC,SAAS,CAAC;AACV,aAAa,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAClD,KAAK,CAAC,CAAC;A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,CAAC,KAAK,CAAC,IAAI,SAAS;AAC3E,kBAAkB,EAAE,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC;AAChC;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs","sources":["fromError.js","toPromise.js","fromPromise.js","throwServerError.js","validateOperation.js","createOperation.js","transformOperation.js"],"sourcesContent":["import { Observable } from '../../utilities';\nexport function fromError(errorValue) {\n return new Observable(function (observer) {\n observer.error(errorValue);\n });\n}\n//# sourceMappingURL=fromError.js.map","import { invariant } from '../../utilities/globals';\nexport function toPromise(observable) {\n var completed = false;\n return new Promise(function (resolve, reject) {\n observable.subscribe({\n next: function (data) {\n if (completed) {\n __DEV__ && invariant.warn(\"Promise Wrapper does not support multiple results from Observable\");\n }\n else {\n completed = true;\n resolve(data);\n }\n },\n error: reject,\n });\n });\n}\n//# sourceMappingURL=toPromise.js.map","import { Observable } from '../../utilities';\nexport function fromPromise(promise) {\n return new Observable(function (observer) {\n promise\n .then(function (value) {\n observer.next(value);\n observer.complete();\n })\n .catch(observer.error.bind(observer));\n });\n}\n//# sourceMappingURL=fromPromise.js.map","export var throwServerError = function (response, result, message) {\n var error = new Error(message);\n error.name = 'ServerError';\n error.response = response;\n error.statusCode = response.status;\n error.result = result;\n throw error;\n};\n//# sourceMappingURL=throwServerError.js.map","import { InvariantError } from '../../utilities/globals';\nexport function validateOperation(operation) {\n var OPERATION_FIELDS = [\n 'query',\n 'operationName',\n 'variables',\n 'extensions',\n 'context',\n ];\n for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {\n var key = _a[_i];\n if (OPERATION_FIELDS.indexOf(key) < 0) {\n throw __DEV__ ? new InvariantError(\"illegal argument: \".concat(key)) : new InvariantError(27);\n }\n }\n return operation;\n}\n//# sourceMappingURL=validateOperation.js.map","import { __assign } from \"tslib\";\nexport function createOperation(starting, operation) {\n var context = __assign({}, starting);\n var setContext = function (next) {\n if (typeof next === 'function') {\n context = __assign(__assign({}, context), next(context));\n }\n else {\n context = __assign(__assign({}, context), next);\n }\n };\n var getContext = function () { return (__assign({}, context)); };\n Object.defineProperty(operation, 'setContext', {\n enumerable: false,\n value: setContext,\n });\n Object.defineProperty(operation, 'getContext', {\n enumerable: false,\n value: getContext,\n });\n return operation;\n}\n//# sourceMappingURL=createOperation.js.map","import { getOperationName } from '../../utilities';\nexport function transformOperation(operation) {\n var transformedOperation = {\n variables: operation.variables || {},\n extensions: operation.extensions || {},\n operationName: operation.operationName,\n query: operation.query,\n };\n if (!transformedOperation.operationName) {\n transformedOperation.operationName =\n typeof transformedOperation.query !== 'string'\n ? getOperationName(transformedOperation.query) || undefined\n : '';\n }\n return transformedOperation;\n}\n//# sourceMappingURL=transformOperation.js.map"],"names":["Observable","invariant","InvariantError","__assign","getOperationName"],"mappings":";;;;;;;;AACO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,OAAO,IAAIA,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACnC,KAAK,CAAC,CAAC;AACP;;ACJO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC;AAC1B,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM,EAAE;AAClD,QAAQ,UAAU,CAAC,SAAS,CAAC;AAC7B,YAAY,IAAI,EAAE,UAAU,IAAI,EAAE;AAClC,gBAAgB,IAAI,SAAS,EAAE;AAC/B,oBAAoB,OAAO,IAAIC,iBAAS,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;AACnH,iBAAiB;AACjB,qBAAqB;AACrB,oBAAoB,SAAS,GAAG,IAAI,CAAC;AACrC,oBAAoB,OAAO,CAAC,IAAI,CAAC,CAAC;AAClC,iBAAiB;AACjB,aAAa;AACb,YAAY,KAAK,EAAE,MAAM;AACzB,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;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AAQ,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,EAAE;AAC5C,QAAQ,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE;AAC9C,QAAQ,aAAa,EAAE,SAAS,CAAC,aAAa;AAC9C,QAAQ,KAAK,EAAE,SAAS,CAAC,KAAK;AAC9B,KAAK,CAAC;AACN,IAAI,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE;AAC7C,QAAQ,oBAAoB,CAAC,aAAa;AAC1C,YAAY,OAAO,oBAAoB,CAAC,KAAK,KAAK,QAAQ;AAC1D,kBAAkBC,0BAAgB,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,SAAS;AAC3E,kBAAkB,EAAE,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,oBAAoB,CAAC;AAChC;;;;;;;;;;"}
@@ -61,7 +61,7 @@ function validateOperation(operation) {
61
61
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
62
62
  var key = _a[_i];
63
63
  if (OPERATION_FIELDS.indexOf(key) < 0) {
64
- throw __DEV__ ? new globals.InvariantError("illegal argument: ".concat(key)) : new globals.InvariantError(26);
64
+ throw __DEV__ ? new globals.InvariantError("illegal argument: ".concat(key)) : new globals.InvariantError(27);
65
65
  }
66
66
  }
67
67
  return operation;
@@ -10,7 +10,7 @@ export function validateOperation(operation) {
10
10
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
11
11
  var key = _a[_i];
12
12
  if (OPERATION_FIELDS.indexOf(key) < 0) {
13
- throw __DEV__ ? new InvariantError("illegal argument: ".concat(key)) : new InvariantError(26);
13
+ throw __DEV__ ? new InvariantError("illegal argument: ".concat(key)) : new InvariantError(27);
14
14
  }
15
15
  }
16
16
  return operation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "3.7.4",
3
+ "version": "3.7.6",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -66,10 +66,10 @@
66
66
  "zen-observable-ts": "^1.2.5"
67
67
  },
68
68
  "devDependencies": {
69
- "@babel/parser": "7.20.7",
69
+ "@babel/parser": "7.20.13",
70
70
  "@changesets/changelog-github": "0.4.8",
71
71
  "@changesets/cli": "2.26.0",
72
- "@graphql-tools/schema": "9.0.12",
72
+ "@graphql-tools/schema": "9.0.14",
73
73
  "@rollup/plugin-node-resolve": "11.2.1",
74
74
  "@testing-library/react": "13.4.0",
75
75
  "@testing-library/react-12": "npm:@testing-library/react@^12",
@@ -77,25 +77,25 @@
77
77
  "@types/bytes": "3.1.1",
78
78
  "@types/fast-json-stable-stringify": "2.0.0",
79
79
  "@types/fetch-mock": "7.3.5",
80
- "@types/glob": "8.0.0",
80
+ "@types/glob": "8.0.1",
81
81
  "@types/hoist-non-react-statics": "3.3.1",
82
- "@types/jest": "29.2.5",
82
+ "@types/jest": "29.2.6",
83
83
  "@types/lodash": "4.14.191",
84
84
  "@types/node": "18.11.18",
85
85
  "@types/node-fetch": "2.6.2",
86
- "@types/react": "18.0.26",
86
+ "@types/react": "18.0.27",
87
87
  "@types/react-dom": "18.0.10",
88
88
  "@types/use-sync-external-store": "0.0.3",
89
- "@typescript-eslint/eslint-plugin": "5.48.1",
90
- "@typescript-eslint/parser": "5.48.1",
91
- "acorn": "8.8.1",
89
+ "@typescript-eslint/eslint-plugin": "5.49.0",
90
+ "@typescript-eslint/parser": "5.49.0",
91
+ "acorn": "8.8.2",
92
92
  "blob-polyfill": "7.0.20220408",
93
93
  "bytes": "3.1.2",
94
94
  "cross-fetch": "3.1.5",
95
- "eslint": "8.31.0",
96
- "eslint-plugin-testing-library": "5.9.1",
95
+ "eslint": "8.33.0",
96
+ "eslint-plugin-testing-library": "5.10.0",
97
97
  "fetch-mock": "9.11.0",
98
- "glob": "8.0.3",
98
+ "glob": "8.1.0",
99
99
  "graphql": "16.6.0",
100
100
  "graphql-ws": "5.11.2",
101
101
  "jest": "29.3.1",
@@ -109,16 +109,16 @@
109
109
  "react-dom-17": "npm:react-dom@^17",
110
110
  "recast": "0.22.0",
111
111
  "resolve": "1.22.1",
112
- "rimraf": "3.0.2",
112
+ "rimraf": "4.1.2",
113
113
  "rollup": "2.79.1",
114
114
  "rollup-plugin-terser": "7.0.2",
115
115
  "rxjs": "7.8.0",
116
116
  "subscriptions-transport-ws": "0.11.0",
117
117
  "terser": "5.16.1",
118
- "ts-jest": "29.0.3",
118
+ "ts-jest": "29.0.5",
119
119
  "ts-node": "10.9.1",
120
120
  "typedoc": "0.22.18",
121
- "typescript": "4.7.4",
121
+ "typescript": "4.9.4",
122
122
  "wait-for-observables": "1.0.3",
123
123
  "web-streams-polyfill": "3.2.1",
124
124
  "whatwg-fetch": "3.6.2"
@@ -2,11 +2,11 @@
2
2
  import * as PropTypes from 'prop-types';
3
3
  import { OperationVariables } from '../../core';
4
4
  import { QueryComponentOptions } from './types';
5
- export declare function Query<TData = any, TVariables = OperationVariables>(props: QueryComponentOptions<TData, TVariables>): JSX.Element | null;
5
+ export declare function Query<TData = any, TVariables extends OperationVariables = OperationVariables>(props: QueryComponentOptions<TData, TVariables>): JSX.Element | null;
6
6
  export declare namespace Query {
7
7
  var propTypes: PropTypes.InferProps<QueryComponentOptions<any, any>>;
8
8
  }
9
- export interface Query<TData, TVariables> {
9
+ export interface Query<TData, TVariables extends OperationVariables> {
10
10
  propTypes: PropTypes.InferProps<QueryComponentOptions<TData, TVariables>>;
11
11
  }
12
12
  //# sourceMappingURL=Query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../src/react/components/Query.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhD,wBAAgB,KAAK,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,kBAAkB,EAChE,KAAK,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,sBAKhD;yBANe,KAAK;;;AAQrB,MAAM,WAAW,KAAK,CAAC,KAAK,EAAE,UAAU;IACtC,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;CAC3E"}
1
+ {"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../src/react/components/Query.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhD,wBAAgB,KAAK,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAC3F,KAAK,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,sBAKhD;yBANe,KAAK;;;AAQrB,MAAM,WAAW,KAAK,CAAC,KAAK,EAAE,UAAU,SAAS,kBAAkB;IACjE,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;CAC3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"Query.js","sourceRoot":"","sources":["../../../src/react/components/Query.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAIxC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,UAAU,KAAK,CACnB,KAA+C;IAEvC,IAAA,QAAQ,GAAwB,KAAK,SAA7B,EAAE,KAAK,GAAiB,KAAK,MAAtB,EAAK,OAAO,UAAK,KAAK,EAAvC,qBAA+B,CAAF,CAAW;IAC9C,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC;AAMD,KAAK,CAAC,SAAS,GAAG;IAChB,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACnC,WAAW,EAAE,SAAS,CAAC,MAAM;IAC7B,2BAA2B,EAAE,SAAS,CAAC,IAAI;IAC3C,WAAW,EAAE,SAAS,CAAC,IAAI;IAC3B,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,GAAG,EAAE,SAAS,CAAC,IAAI;IACnB,cAAc,EAAE,SAAS,CAAC,IAAI;IAC9B,iBAAiB,EAAE,SAAS,CAAC,IAAI;CACF,CAAC","sourcesContent":["import * as PropTypes from 'prop-types';\n\nimport { OperationVariables } from '../../core';\nimport { QueryComponentOptions } from './types';\nimport { useQuery } from '../hooks';\n\nexport function Query<TData = any, TVariables = OperationVariables>(\n props: QueryComponentOptions<TData, TVariables>\n) {\n const { children, query, ...options } = props;\n const result = useQuery(query, options);\n return result ? children(result as any) : null;\n}\n\nexport interface Query<TData, TVariables> {\n propTypes: PropTypes.InferProps<QueryComponentOptions<TData, TVariables>>;\n}\n\nQuery.propTypes = {\n client: PropTypes.object,\n children: PropTypes.func.isRequired,\n fetchPolicy: PropTypes.string,\n notifyOnNetworkStatusChange: PropTypes.bool,\n onCompleted: PropTypes.func,\n onError: PropTypes.func,\n pollInterval: PropTypes.number,\n query: PropTypes.object.isRequired,\n variables: PropTypes.object,\n ssr: PropTypes.bool,\n partialRefetch: PropTypes.bool,\n returnPartialData: PropTypes.bool\n} as Query<any, any>[\"propTypes\"];\n"]}
1
+ {"version":3,"file":"Query.js","sourceRoot":"","sources":["../../../src/react/components/Query.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAIxC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,UAAU,KAAK,CACnB,KAA+C;IAEvC,IAAA,QAAQ,GAAwB,KAAK,SAA7B,EAAE,KAAK,GAAiB,KAAK,MAAtB,EAAK,OAAO,UAAK,KAAK,EAAvC,qBAA+B,CAAF,CAAW;IAC9C,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC;AAMD,KAAK,CAAC,SAAS,GAAG;IAChB,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACnC,WAAW,EAAE,SAAS,CAAC,MAAM;IAC7B,2BAA2B,EAAE,SAAS,CAAC,IAAI;IAC3C,WAAW,EAAE,SAAS,CAAC,IAAI;IAC3B,OAAO,EAAE,SAAS,CAAC,IAAI;IACvB,YAAY,EAAE,SAAS,CAAC,MAAM;IAC9B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,GAAG,EAAE,SAAS,CAAC,IAAI;IACnB,cAAc,EAAE,SAAS,CAAC,IAAI;IAC9B,iBAAiB,EAAE,SAAS,CAAC,IAAI;CACF,CAAC","sourcesContent":["import * as PropTypes from 'prop-types';\n\nimport { OperationVariables } from '../../core';\nimport { QueryComponentOptions } from './types';\nimport { useQuery } from '../hooks';\n\nexport function Query<TData = any, TVariables extends OperationVariables = OperationVariables>(\n props: QueryComponentOptions<TData, TVariables>\n) {\n const { children, query, ...options } = props;\n const result = useQuery(query, options);\n return result ? children(result as any) : null;\n}\n\nexport interface Query<TData, TVariables extends OperationVariables> {\n propTypes: PropTypes.InferProps<QueryComponentOptions<TData, TVariables>>;\n}\n\nQuery.propTypes = {\n client: PropTypes.object,\n children: PropTypes.func.isRequired,\n fetchPolicy: PropTypes.string,\n notifyOnNetworkStatusChange: PropTypes.bool,\n onCompleted: PropTypes.func,\n onError: PropTypes.func,\n pollInterval: PropTypes.number,\n query: PropTypes.object.isRequired,\n variables: PropTypes.object,\n ssr: PropTypes.bool,\n partialRefetch: PropTypes.bool,\n returnPartialData: PropTypes.bool\n} as Query<any, any>[\"propTypes\"];\n"]}
@@ -2,11 +2,11 @@
2
2
  import * as PropTypes from 'prop-types';
3
3
  import { OperationVariables } from '../../core';
4
4
  import { SubscriptionComponentOptions } from './types';
5
- export declare function Subscription<TData = any, TVariables = OperationVariables>(props: SubscriptionComponentOptions<TData, TVariables>): JSX.Element | null;
5
+ export declare function Subscription<TData = any, TVariables extends OperationVariables = OperationVariables>(props: SubscriptionComponentOptions<TData, TVariables>): JSX.Element | null;
6
6
  export declare namespace Subscription {
7
7
  var propTypes: PropTypes.InferProps<SubscriptionComponentOptions<any, any>>;
8
8
  }
9
- export interface Subscription<TData, TVariables> {
9
+ export interface Subscription<TData, TVariables extends OperationVariables> {
10
10
  propTypes: PropTypes.InferProps<SubscriptionComponentOptions<TData, TVariables>>;
11
11
  }
12
12
  //# sourceMappingURL=Subscription.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Subscription.d.ts","sourceRoot":"","sources":["../../../src/react/components/Subscription.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAGvD,wBAAgB,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,kBAAkB,EACvE,KAAK,EAAE,4BAA4B,CAAC,KAAK,EAAE,UAAU,CAAC,sBAIvD;yBALe,YAAY;;;AAO5B,MAAM,WAAW,YAAY,CAAC,KAAK,EAAE,UAAU;IAC7C,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,4BAA4B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;CAClF"}
1
+ {"version":3,"file":"Subscription.d.ts","sourceRoot":"","sources":["../../../src/react/components/Subscription.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAGvD,wBAAgB,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAClG,KAAK,EAAE,4BAA4B,CAAC,KAAK,EAAE,UAAU,CAAC,sBAIvD;yBALe,YAAY;;;AAO5B,MAAM,WAAW,YAAY,CAAC,KAAK,EAAE,UAAU,SAAS,kBAAkB;IACxE,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,4BAA4B,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;CAClF"}
@@ -1 +1 @@
1
- {"version":3,"file":"Subscription.js","sourceRoot":"","sources":["../../../src/react/components/Subscription.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,UAAU,YAAY,CAC1B,KAAsD;IAEtD,IAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAMD,YAAY,CAAC,SAAS,GAAG;IACvB,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACzC,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,kBAAkB,EAAE,SAAS,CAAC,IAAI;IAClC,MAAM,EAAE,SAAS,CAAC,IAAI;IACtB,sBAAsB,EAAE,SAAS,CAAC,IAAI;IACtC,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,iBAAiB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC","sourcesContent":["import * as PropTypes from 'prop-types';\n\nimport { OperationVariables } from '../../core';\nimport { SubscriptionComponentOptions } from './types';\nimport { useSubscription } from '../hooks';\n\nexport function Subscription<TData = any, TVariables = OperationVariables>(\n props: SubscriptionComponentOptions<TData, TVariables>\n) {\n const result = useSubscription(props.subscription, props);\n return props.children && result ? props.children(result) : null;\n}\n\nexport interface Subscription<TData, TVariables> {\n propTypes: PropTypes.InferProps<SubscriptionComponentOptions<TData, TVariables>>;\n}\n\nSubscription.propTypes = {\n subscription: PropTypes.object.isRequired,\n variables: PropTypes.object,\n children: PropTypes.func,\n onSubscriptionData: PropTypes.func,\n onData: PropTypes.func,\n onSubscriptionComplete: PropTypes.func,\n onComplete: PropTypes.func,\n shouldResubscribe: PropTypes.oneOfType([PropTypes.func, PropTypes.bool])\n} as Subscription<any, any>[\"propTypes\"];\n"]}
1
+ {"version":3,"file":"Subscription.js","sourceRoot":"","sources":["../../../src/react/components/Subscription.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,UAAU,YAAY,CAC1B,KAAsD;IAEtD,IAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAMD,YAAY,CAAC,SAAS,GAAG;IACvB,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACzC,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,kBAAkB,EAAE,SAAS,CAAC,IAAI;IAClC,MAAM,EAAE,SAAS,CAAC,IAAI;IACtB,sBAAsB,EAAE,SAAS,CAAC,IAAI;IACtC,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,iBAAiB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC","sourcesContent":["import * as PropTypes from 'prop-types';\n\nimport { OperationVariables } from '../../core';\nimport { SubscriptionComponentOptions } from './types';\nimport { useSubscription } from '../hooks';\n\nexport function Subscription<TData = any, TVariables extends OperationVariables = OperationVariables>(\n props: SubscriptionComponentOptions<TData, TVariables>\n) {\n const result = useSubscription(props.subscription, props);\n return props.children && result ? props.children(result) : null;\n}\n\nexport interface Subscription<TData, TVariables extends OperationVariables> {\n propTypes: PropTypes.InferProps<SubscriptionComponentOptions<TData, TVariables>>;\n}\n\nSubscription.propTypes = {\n subscription: PropTypes.object.isRequired,\n variables: PropTypes.object,\n children: PropTypes.func,\n onSubscriptionData: PropTypes.func,\n onData: PropTypes.func,\n onSubscriptionComplete: PropTypes.func,\n onComplete: PropTypes.func,\n shouldResubscribe: PropTypes.oneOfType([PropTypes.func, PropTypes.bool])\n} as Subscription<any, any>[\"propTypes\"];\n"]}
@@ -3,7 +3,7 @@ import { DocumentNode } from 'graphql';
3
3
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  import { OperationVariables, DefaultContext, ApolloCache } from '../../core';
5
5
  import { QueryFunctionOptions, QueryResult, BaseMutationOptions, MutationFunction, MutationResult, BaseSubscriptionOptions, SubscriptionResult } from '../types/types';
6
- export interface QueryComponentOptions<TData = any, TVariables = OperationVariables> extends QueryFunctionOptions<TData, TVariables> {
6
+ export interface QueryComponentOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends QueryFunctionOptions<TData, TVariables> {
7
7
  children: (result: QueryResult<TData, TVariables>) => JSX.Element | null;
8
8
  query: DocumentNode | TypedDocumentNode<TData, TVariables>;
9
9
  }
@@ -11,7 +11,7 @@ export interface MutationComponentOptions<TData = any, TVariables = OperationVar
11
11
  mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
12
12
  children: (mutateFunction: MutationFunction<TData, TVariables, TContext>, result: MutationResult<TData>) => JSX.Element | null;
13
13
  }
14
- export interface SubscriptionComponentOptions<TData = any, TVariables = OperationVariables> extends BaseSubscriptionOptions<TData, TVariables> {
14
+ export interface SubscriptionComponentOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseSubscriptionOptions<TData, TVariables> {
15
15
  subscription: DocumentNode | TypedDocumentNode<TData, TVariables>;
16
16
  children?: null | ((result: SubscriptionResult<TData>) => JSX.Element | null);
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/components/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,qBAAqB,CACpC,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,CAC/B,SAAQ,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC;IAC/C,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,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