Skip to content

Commit

Permalink
adjust some more
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Jul 9, 2024
1 parent aac564e commit 4a3bdc0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-berries-yawn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ This was a type bug - these errors were never `GraphQLError` instances
to begin with, and the `GraphQLError` class has additional properties that can
never be correctly rehydrated from a GraphQL result.
The correct type to use here is `GraphQLFormattedError`.

Similarly, please ensure to use types like
* `FormattedExecutionResult` instead of `ExecutionResult`
the non-"Formatted" versions are for use on the server only,
not for use in client code.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
"GraphQLError": {
"message": "Use GraphQLFormattedError instead",
"fixWith": "GraphQLFormattedError"
},
"ExecutionResult": {
"message": "Use FormattedExecutionResult instead",
"fixWith": "FormattedExecutionResult"
}
},
"extendDefaults": false
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { cloneDeep, assign } from "lodash";
import {
GraphQLError,
ExecutionResult,
DocumentNode,
Kind,
print,
visit,
FormattedExecutionResult,
} from "graphql";
import gql from "graphql-tag";

Expand Down Expand Up @@ -752,7 +752,7 @@ describe("client", () => {
cache: new InMemoryCache({ addTypename: false }),
});

return client.query({ query }).then((result: ExecutionResult) => {
return client.query({ query }).then((result: FormattedExecutionResult) => {
expect(result.data).toEqual(data);
});
});
Expand Down Expand Up @@ -6411,7 +6411,7 @@ function clientRoundtrip(
resolve: (result: any) => any,
reject: (reason: any) => any,
query: DocumentNode,
data: ExecutionResult,
data: FormattedExecutionResult,
variables?: any,
possibleTypes?: PossibleTypesMap
) {
Expand Down
8 changes: 6 additions & 2 deletions src/react/components/__tests__/client/Mutation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React, { useState, PropsWithChildren } from "react";
import gql from "graphql-tag";
import { ExecutionResult, GraphQLError } from "graphql";
import {
ExecutionResult,
FormattedExecutionResult,
GraphQLError,
} from "graphql";
import userEvent from "@testing-library/user-event";
import { render, screen, waitFor, act } from "@testing-library/react";

Expand Down Expand Up @@ -1195,7 +1199,7 @@ describe("General Mutation testing", () => {
}));

it("has an update prop for updating the store after the mutation", async () => {
const update = (_proxy: DataProxy, response: ExecutionResult) => {
const update = (_proxy: DataProxy, response: FormattedExecutionResult) => {
expect(response.data).toEqual(data);
};

Expand Down

0 comments on commit 4a3bdc0

Please sign in to comment.