refactor: improve support for persistent queries #110
Annotations
11 errors and 2 warnings
src/client.test.ts > gqlClientFetch > should perform a query:
src/client.test.ts#L50
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?op=myQuery",
+ "https://localhost/graphql",
{
- "body": "{\"query\":\"\\n\\tquery myQuery {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{}}",
+ "body": "{\"operationName\":\"myQuery\",\"query\":\"\\n\\tquery myQuery {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae\"}}}",
"credentials": "include",
"headers": {
"content-type": "application/json",
},
"method": "POST",
- "signal": Any<AbortSignal>,
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
},
]
Number of calls: 1
❯ src/client.test.ts:50:23
|
src/client.test.ts > gqlClientFetch > should perform a persisted query when enabled:
src/client.test.ts#L76
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?op=myQuery&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D&variables=%7B%22myVar%22%3A%22baz%22%7D",
+ "https://localhost/graphql?query=%0A%09query+myQuery+%7B%0A%09%09foo%0A%09%09bar%0A%09%7D%0A&operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
{
"credentials": "include",
"headers": {
"content-type": "application/json",
},
"method": "GET",
- "signal": Any<AbortSignal>,
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
},
]
Number of calls: 1
❯ src/client.test.ts:76:23
|
src/client.test.ts > gqlClientFetch > should perform a mutation:
src/client.test.ts#L98
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?op=myMutation",
- Anything,
+ "https://localhost/graphql",
+ {
+ "body": "{\"operationName\":\"myMutation\",\"query\":\"\\n\\tmutation myMutation {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"2d05ccd16b495c9d2f3449a29bdba388f843f46a1b225c18b5c5efd108ede0ee\"}}}",
+ "credentials": "include",
+ "headers": {
+ "content-type": "application/json",
+ },
+ "method": "POST",
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
+ },
]
Number of calls: 1
❯ src/client.test.ts:98:23
|
src/client.test.ts > gqlClientFetch > should fallback to POST when persisted query is not found on the server:
src/client.test.ts#L125
AssertionError: expected { Object (errors) } to deeply equal { foo: 'foo', bar: 'bar' }
- Expected
+ Received
{
- "bar": "bar",
- "foo": "foo",
+ "errors": [
+ {
+ "message": "PersistedQueryNotFound",
+ },
+ ],
}
❯ src/client.test.ts:125:23
|
src/client.test.ts > gqlClientFetch > should allow passing extra HTTP headers:
src/client.test.ts#L229
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?op=myQuery",
+ "https://localhost/graphql",
{
- "body": "{\"query\":\"\\n\\tquery myQuery {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{}}",
+ "body": "{\"operationName\":\"myQuery\",\"query\":\"\\n\\tquery myQuery {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae\"}}}",
"credentials": "include",
"headers": {
"content-type": "application/json",
"x-extra-header": "foo",
},
"method": "POST",
- "signal": Any<AbortSignal>,
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
},
]
Number of calls: 1
❯ src/client.test.ts:229:23
|
src/server.test.ts > gqlServerFetch > should fetch a persisted query:
src/server.test.ts#L46
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
+ "https://localhost/graphql?query=%0A%09query+myQuery+%7B%0A%09%09foo%0A%09%09bar%0A%09%7D%0A&operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
{
"cache": "force-cache",
- "headers": {
- "Content-Type": "application/json",
- },
+ "headers": undefined,
"method": "GET",
"next": {
"revalidate": 900,
},
- "signal": Any<AbortSignal>,
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
},
]
Number of calls: 1
❯ src/server.test.ts:46:23
|
src/server.test.ts > gqlServerFetch > should persist the query if it wasn't persisted yet:
src/server.test.ts#L77
AssertionError: expected 2nd "spy" call to have been called with [ 'https://localhost/graphql', …(1) ]
- Expected
+ Received
[
"https://localhost/graphql",
{
- "body": "{\"operationName\":\"myQuery\",\"query\":\"\\n\\tquery myQuery {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"}}",
- "headers": {
- "Content-Type": "application/json",
- },
+ "body": "{\"operationName\":\"myQuery\",\"query\":\"\\n\\tquery myQuery {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae\"}}}",
+ "cache": undefined,
+ "headers": undefined,
"method": "POST",
"next": {
"revalidate": 900,
},
"signal": Any<AbortSignal>,
},
]
❯ src/server.test.ts:77:23
|
src/server.test.ts > gqlServerFetch > should skip persisted queries if operation is a mutation:
src/server.test.ts#L110
AssertionError: expected 1st "spy" call to have been called with [ 'https://localhost/graphql', …(1) ]
- Expected
+ Received
[
"https://localhost/graphql",
{
- "body": "{\"operationName\":\"myMutation\",\"query\":\"\\n\\tmutation myMutation {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"}}",
- "headers": {
- "Content-Type": "application/json",
+ "body": "{\"operationName\":\"myMutation\",\"query\":\"\\n\\tmutation myMutation {\\n\\t\\tfoo\\n\\t\\tbar\\n\\t}\\n\",\"variables\":{\"myVar\":\"baz\"},\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"2d05ccd16b495c9d2f3449a29bdba388f843f46a1b225c18b5c5efd108ede0ee\"}}}",
+ "cache": undefined,
+ "headers": Headers {
+ Symbol(map): {
+ "Content-Type": [
+ "application/json",
+ ],
+ },
},
"method": "POST",
"next": {
"revalidate": 900,
},
"signal": Any<AbortSignal>,
},
]
❯ src/server.test.ts:110:23
|
src/server.test.ts > gqlServerFetch > should fetch a persisted query without revalidate:
src/server.test.ts#L149
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
+ "https://localhost/graphql?query=%0A%09query+myQuery+%7B%0A%09%09foo%0A%09%09bar%0A%09%7D%0A&operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
{
"cache": "no-store",
- "headers": {
- "Content-Type": "application/json",
- },
+ "headers": undefined,
"method": "GET",
"next": {
"revalidate": undefined,
},
- "signal": Any<AbortSignal>,
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
},
]
Number of calls: 1
❯ src/server.test.ts:149:23
|
src/server.test.ts > gqlServerFetch > should fetch a with custom headers:
src/server.test.ts#L187
AssertionError: expected "spy" to be called with arguments: [ …(2) ]
Received:
1st spy call:
[
- "https://localhost/graphql?operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
+ "https://localhost/graphql?query=%0A%09query+myQuery+%7B%0A%09%09foo%0A%09%09bar%0A%09%7D%0A&operationName=myQuery&variables=%7B%22myVar%22%3A%22baz%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e5276e0694f661ef818210402d06d249625ef169a1c2b60383acb2c42d45f7ae%22%7D%7D",
{
"cache": "force-cache",
"headers": {
- "Content-Type": "application/json",
"x-custom-header": "foo",
},
"method": "GET",
"next": {
"revalidate": 900,
},
- "signal": Any<AbortSignal>,
+ "signal": AbortSignal {
+ Symbol(kEvents): Map {},
+ Symbol(events.maxEventTargetListeners): 10,
+ Symbol(events.maxEventTargetListenersWarned): false,
+ Symbol(kHandlers): Map {},
+ Symbol(kAborted): false,
+ Symbol(kReason): undefined,
+ Symbol(kComposite): false,
+ Symbol(kTimeout): true,
+ },
},
]
Number of calls: 1
❯ src/server.test.ts:187:23
|
Build, and test on Node 22.x and ubuntu-latest
The job was canceled because "_20_x_ubuntu-latest" failed.
|
Lint codebase
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
|
Build, and test on Node 20.x and ubuntu-latest
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
|