@graphql-tools/executor-http 3.2.1 → 3.3.0-alpha-5ebaf88a5d16108f68730172d579a3f0748c97a3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @graphql-tools/executor-http
2
2
 
3
+ ## 3.3.0-alpha-5ebaf88a5d16108f68730172d579a3f0748c97a3
4
+ ### Minor Changes
5
+
6
+
7
+
8
+ - [#2334](https://github.com/graphql-hive/gateway/pull/2334) [`d8a1801`](https://github.com/graphql-hive/gateway/commit/d8a1801379b81d642afe5874d3a46281181b68d5) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Add `useGETForHashedQueries` support for downstream APQ requests so hash-only
9
+ query probes can use GET while full-query fallbacks continue to use POST.
10
+
11
+ Add the `useContentTypeForGETRequests` opt-in for GET requests that need
12
+ `content-type: application/json` compatibility.
13
+
3
14
  ## 3.2.1
4
15
  ### Patch Changes
5
16
 
package/dist/index.cjs CHANGED
@@ -553,7 +553,7 @@ function buildHTTPExecutor(options) {
553
553
  let method = request.extensions?.method || options?.method;
554
554
  const operationAst = utils.getOperationASTFromRequest(request);
555
555
  const operationType = operationAst.operation;
556
- if ((options?.useGETForQueries || request.extensions?.useGETForQueries) && operationType === "query") {
556
+ if (operationType === "query" && (options?.useGETForQueries || request.extensions?.useGETForQueries || (options?.useGETForHashedQueries || request.extensions?.useGETForHashedQueries) && excludeQuery)) {
557
557
  method = "GET";
558
558
  }
559
559
  let accept = "application/graphql-response+json, application/json, multipart/mixed";
@@ -863,6 +863,9 @@ function buildHTTPExecutor(options) {
863
863
  (body) => {
864
864
  switch (method) {
865
865
  case "GET": {
866
+ if ((options?.useContentTypeForGETRequests || request.extensions?.useContentTypeForGETRequests) && !headers["content-type"]) {
867
+ headers["content-type"] = "application/json";
868
+ }
866
869
  const finalUrl = prepareGETUrl({
867
870
  baseUrl: endpoint,
868
871
  body
package/dist/index.d.cts CHANGED
@@ -32,6 +32,18 @@ interface HTTPExecutorOptions {
32
32
  * @default false
33
33
  */
34
34
  useGETForQueries?: boolean;
35
+ /**
36
+ * Whether to use the GET HTTP method for hashed Automatic Persisted Query requests.
37
+ * Full query fallbacks and mutations continue to use POST.
38
+ * @default false
39
+ */
40
+ useGETForHashedQueries?: boolean;
41
+ /**
42
+ * Whether to set `content-type: application/json` on GET requests when one isn't already provided.
43
+ * This can be useful for compatibility with servers that require a preflighted GET request.
44
+ * @default false
45
+ */
46
+ useContentTypeForGETRequests?: boolean;
35
47
  /**
36
48
  * Additional headers to include when querying the original schema
37
49
  */
package/dist/index.d.ts CHANGED
@@ -32,6 +32,18 @@ interface HTTPExecutorOptions {
32
32
  * @default false
33
33
  */
34
34
  useGETForQueries?: boolean;
35
+ /**
36
+ * Whether to use the GET HTTP method for hashed Automatic Persisted Query requests.
37
+ * Full query fallbacks and mutations continue to use POST.
38
+ * @default false
39
+ */
40
+ useGETForHashedQueries?: boolean;
41
+ /**
42
+ * Whether to set `content-type: application/json` on GET requests when one isn't already provided.
43
+ * This can be useful for compatibility with servers that require a preflighted GET request.
44
+ * @default false
45
+ */
46
+ useContentTypeForGETRequests?: boolean;
35
47
  /**
36
48
  * Additional headers to include when querying the original schema
37
49
  */
package/dist/index.js CHANGED
@@ -551,7 +551,7 @@ function buildHTTPExecutor(options) {
551
551
  let method = request.extensions?.method || options?.method;
552
552
  const operationAst = getOperationASTFromRequest(request);
553
553
  const operationType = operationAst.operation;
554
- if ((options?.useGETForQueries || request.extensions?.useGETForQueries) && operationType === "query") {
554
+ if (operationType === "query" && (options?.useGETForQueries || request.extensions?.useGETForQueries || (options?.useGETForHashedQueries || request.extensions?.useGETForHashedQueries) && excludeQuery)) {
555
555
  method = "GET";
556
556
  }
557
557
  let accept = "application/graphql-response+json, application/json, multipart/mixed";
@@ -861,6 +861,9 @@ function buildHTTPExecutor(options) {
861
861
  (body) => {
862
862
  switch (method) {
863
863
  case "GET": {
864
+ if ((options?.useContentTypeForGETRequests || request.extensions?.useContentTypeForGETRequests) && !headers["content-type"]) {
865
+ headers["content-type"] = "application/json";
866
+ }
864
867
  const finalUrl = prepareGETUrl({
865
868
  baseUrl: endpoint,
866
869
  body
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor-http",
3
- "version": "3.2.1",
3
+ "version": "3.3.0-alpha-5ebaf88a5d16108f68730172d579a3f0748c97a3",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {