Skip to content

Commit 2dd16e9

Browse files
committed
feat: Upgrade graphql and@apollo/client
1 parent 28f518c commit 2dd16e9

9 files changed

Lines changed: 64 additions & 38 deletions

File tree

examples/demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"dependencies": {
7-
"@apollo/client": "^3.12.4",
7+
"@apollo/client": "^4.1.6",
88
"@mui/icons-material": "^7.0.0",
99
"@mui/material": "^7.0.0",
1010
"@types/recharts": "^1.8.10",
@@ -14,7 +14,7 @@
1414
"date-fns": "^3.6.0",
1515
"echarts": "^5.6.0",
1616
"fakerest": "^4.2.0",
17-
"graphql": "^15.6.0",
17+
"graphql": "^16.13.2",
1818
"graphql-tag": "^2.12.6",
1919
"inflection": "^3.0.0",
2020
"json-graphql-server": "^3.0.1",

examples/demo/src/dataProvider/graphql.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApolloQueryResult } from '@apollo/client';
1+
import { ObservableQuery } from '@apollo/client';
22
import buildApolloClient, {
33
buildQuery as buildQueryFactory,
44
} from 'ra-data-graphql-simple';
@@ -44,7 +44,7 @@ const customBuildQuery: BuildQueryFactory = introspectionResults => {
4444
}
4545
}`,
4646
variables: { id: params.id },
47-
parseResponse: ({ data }: ApolloQueryResult<any>) => {
47+
parseResponse: ({ data }: ObservableQuery.Result<any>) => {
4848
if (data[`remove${resource}`]) {
4949
return { data: { id: params.id } };
5050
}
@@ -98,7 +98,7 @@ const customBuildQuery: BuildQueryFactory = introspectionResults => {
9898
}
9999
`,
100100
variables: params.data,
101-
parseResponse: ({ data }: ApolloQueryResult<any>) => {
101+
parseResponse: ({ data }: ObservableQuery.Result<any>) => {
102102
if (data.createCustomer) {
103103
return { data: { id: data.createCustomer.id } };
104104
}

packages/ra-data-graphql-simple/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"build": "zshy --silent"
3333
},
3434
"dependencies": {
35-
"@apollo/client": "^3.3.19",
35+
"@apollo/client": "^4.1.6",
3636
"graphql-ast-types-browser": "~1.0.2",
3737
"lodash": "~4.17.5",
3838
"pluralize": "~7.0.0",
@@ -43,7 +43,7 @@
4343
"ra-core": "^5.0.0"
4444
},
4545
"devDependencies": {
46-
"graphql": "^15.6.0",
46+
"graphql": "^16.13.2",
4747
"typescript": "^5.1.3",
4848
"zshy": "^0.5.0"
4949
},

packages/ra-data-graphql-simple/src/getResponseParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import {
77
} from 'ra-core';
88
import { IntrospectionResult, IntrospectedResource } from 'ra-data-graphql';
99
import { IntrospectionField } from 'graphql';
10-
import { ApolloQueryResult } from '@apollo/client';
10+
import { ObservableQuery } from '@apollo/client';
1111

1212
export default (_introspectionResults: IntrospectionResult) =>
1313
(
1414
raFetchMethod: string,
1515
_resource: IntrospectedResource,
1616
_queryType: IntrospectionField
1717
) =>
18-
(response: ApolloQueryResult<any>) => {
18+
(response: ObservableQuery.Result<any>) => {
1919
const data = response.data;
2020

2121
if (

packages/ra-data-graphql/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"build": "zshy --silent"
3333
},
3434
"dependencies": {
35-
"@apollo/client": "^3.3.19",
35+
"@apollo/client": "^4.1.6",
3636
"graphql-tag": "^2.12.6",
3737
"lodash": "~4.17.5",
3838
"pluralize": "~7.0.0"
@@ -42,7 +42,7 @@
4242
"ra-core": "^5.0.0"
4343
},
4444
"devDependencies": {
45-
"graphql": "^15.6.0",
45+
"graphql": "^16.13.2",
4646
"typescript": "^5.1.3",
4747
"zshy": "^0.5.0"
4848
},

packages/ra-data-graphql/src/buildApolloClient.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import {
22
ApolloClient,
3-
ApolloClientOptions,
4-
HttpLink,
53
InMemoryCache,
4+
HttpLink,
5+
type ApolloClientOptions,
66
} from '@apollo/client';
77

88
export default (options?: Partial<ApolloClientOptions<unknown>>) => {
99
if (!options) {
1010
return new ApolloClient({
1111
cache: new InMemoryCache().restore({}),
12+
link: new HttpLink({}),
1213
});
1314
}
1415

1516
const {
1617
cache = new InMemoryCache().restore({}),
17-
uri,
18-
credentials,
19-
headers,
20-
link = uri ? new HttpLink({ uri, credentials, headers }) : undefined,
18+
link,
2119
...otherOptions
2220
} = options;
2321

packages/ra-data-graphql/src/index.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ApolloClient, ApolloError } from '@apollo/client';
1+
import { ApolloClient } from '@apollo/client';
2+
import { ApolloError } from '@apollo/client/v4-migration';
23
import { GraphQLError } from 'graphql';
34
import gql from 'graphql-tag';
45

@@ -10,9 +11,7 @@ describe('GraphQL data provider', () => {
1011
it('sets ApolloError in body', async () => {
1112
const mockClient = {
1213
mutate: async () => {
13-
throw new ApolloError({
14-
graphQLErrors: [new GraphQLError('some error')],
15-
});
14+
throw new GraphQLError('some error');
1615
},
1716
};
1817
const mockBuildQueryFactory = () => {
@@ -28,7 +27,7 @@ describe('GraphQL data provider', () => {
2827
});
2928
};
3029
const dataProvider = await buildDataProvider({
31-
client: mockClient as unknown as ApolloClient<unknown>,
30+
client: mockClient as unknown as ApolloClient,
3231
introspection: false,
3332
buildQuery:
3433
mockBuildQueryFactory as unknown as BuildQueryFactory,
@@ -81,7 +80,7 @@ describe('GraphQL data provider', () => {
8180
};
8281

8382
const dataProvider = buildDataProvider({
84-
client: client as unknown as ApolloClient<unknown>,
83+
client: client as unknown as ApolloClient,
8584
buildQuery: () => () => undefined,
8685
});
8786

packages/ra-data-graphql/src/introspection.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ALL_TYPES } from './constants';
1515
* @param {Object} options The introspection options
1616
*/
1717
export const introspectSchema = async (
18-
client: ApolloClient<unknown>,
18+
client: ApolloClient,
1919
options: IntrospectionOptions
2020
) => {
2121
const schema = options.schema ? options.schema : await fetchSchema(client);
@@ -50,9 +50,7 @@ export type IntrospectionResult = {
5050
schema: IntrospectionSchema;
5151
};
5252

53-
const fetchSchema = (
54-
client: ApolloClient<unknown>
55-
): Promise<IntrospectionSchema> =>
53+
const fetchSchema = (client: ApolloClient): Promise<IntrospectionSchema> =>
5654
client
5755
.query<IntrospectionQuery>({
5856
fetchPolicy: 'network-only',

yarn.lock

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ __metadata:
3535
languageName: node
3636
linkType: hard
3737

38-
"@apollo/client@npm:^3.12.4, @apollo/client@npm:^3.3.19, @apollo/client@npm:^3.9.11":
38+
"@apollo/client@npm:^3.9.11":
3939
version: 3.12.4
4040
resolution: "@apollo/client@npm:3.12.4"
4141
dependencies:
@@ -72,6 +72,37 @@ __metadata:
7272
languageName: node
7373
linkType: hard
7474

75+
"@apollo/client@npm:^4.1.6":
76+
version: 4.1.6
77+
resolution: "@apollo/client@npm:4.1.6"
78+
dependencies:
79+
"@graphql-typed-document-node/core": "npm:^3.1.1"
80+
"@wry/caches": "npm:^1.0.0"
81+
"@wry/equality": "npm:^0.5.6"
82+
"@wry/trie": "npm:^0.5.0"
83+
graphql-tag: "npm:^2.12.6"
84+
optimism: "npm:^0.18.0"
85+
tslib: "npm:^2.3.0"
86+
peerDependencies:
87+
graphql: ^16.0.0
88+
graphql-ws: ^5.5.5 || ^6.0.3
89+
react: ^17.0.0 || ^18.0.0 || >=19.0.0-rc
90+
react-dom: ^17.0.0 || ^18.0.0 || >=19.0.0-rc
91+
rxjs: ^7.3.0
92+
subscriptions-transport-ws: ^0.9.0 || ^0.11.0
93+
peerDependenciesMeta:
94+
graphql-ws:
95+
optional: true
96+
react:
97+
optional: true
98+
react-dom:
99+
optional: true
100+
subscriptions-transport-ws:
101+
optional: true
102+
checksum: ff152317932cb0ba46423161d388d1a2bc0bbc6c8ec6e2e85e915bb2ec22f461effa6fd2bbc8b754babd75ac8b52843f1e3ddf8e501cbe1d9b857e4df2f2f2df
103+
languageName: node
104+
linkType: hard
105+
75106
"@astrojs/compiler@npm:^2.13.0, @astrojs/compiler@npm:^2.9.1":
76107
version: 2.13.0
77108
resolution: "@astrojs/compiler@npm:2.13.0"
@@ -10852,7 +10883,7 @@ __metadata:
1085210883
version: 0.0.0-use.local
1085310884
resolution: "demo@workspace:examples/demo"
1085410885
dependencies:
10855-
"@apollo/client": "npm:^3.12.4"
10886+
"@apollo/client": "npm:^4.1.6"
1085610887
"@mui/icons-material": "npm:^7.0.0"
1085710888
"@mui/material": "npm:^7.0.0"
1085810889
"@types/jest": "npm:^29.5.2"
@@ -10866,7 +10897,7 @@ __metadata:
1086610897
date-fns: "npm:^3.6.0"
1086710898
echarts: "npm:^5.6.0"
1086810899
fakerest: "npm:^4.2.0"
10869-
graphql: "npm:^15.6.0"
10900+
graphql: "npm:^16.13.2"
1087010901
graphql-tag: "npm:^2.12.6"
1087110902
inflection: "npm:^3.0.0"
1087210903
json-graphql-server: "npm:^3.0.1"
@@ -13665,10 +13696,10 @@ __metadata:
1366513696
languageName: node
1366613697
linkType: hard
1366713698

13668-
"graphql@npm:^15.6.0":
13669-
version: 15.8.0
13670-
resolution: "graphql@npm:15.8.0"
13671-
checksum: 30cc09b77170a9d1ed68e4c017ec8c5265f69501c96e4f34f8f6613f39a886c96dd9853eac925f212566ed651736334c8fe24ceae6c44e8d7625c95c3009a801
13699+
"graphql@npm:^16.13.2":
13700+
version: 16.13.2
13701+
resolution: "graphql@npm:16.13.2"
13702+
checksum: 64e822a0a0e4398781e4bc9765b88d370c08261498b517add4b878038ef7be2005b6b394a79a5102b9379d57052f60bc7f23fec8f39808d101984a74772ebd9d
1367213703
languageName: node
1367313704
linkType: hard
1367413705

@@ -20803,8 +20834,8 @@ __metadata:
2080320834
version: 0.0.0-use.local
2080420835
resolution: "ra-data-graphql-simple@workspace:packages/ra-data-graphql-simple"
2080520836
dependencies:
20806-
"@apollo/client": "npm:^3.3.19"
20807-
graphql: "npm:^15.6.0"
20837+
"@apollo/client": "npm:^4.1.6"
20838+
graphql: "npm:^16.13.2"
2080820839
graphql-ast-types-browser: "npm:~1.0.2"
2080920840
lodash: "npm:~4.17.5"
2081020841
pluralize: "npm:~7.0.0"
@@ -20821,8 +20852,8 @@ __metadata:
2082120852
version: 0.0.0-use.local
2082220853
resolution: "ra-data-graphql@workspace:packages/ra-data-graphql"
2082320854
dependencies:
20824-
"@apollo/client": "npm:^3.3.19"
20825-
graphql: "npm:^15.6.0"
20855+
"@apollo/client": "npm:^4.1.6"
20856+
graphql: "npm:^16.13.2"
2082620857
graphql-tag: "npm:^2.12.6"
2082720858
lodash: "npm:~4.17.5"
2082820859
pluralize: "npm:~7.0.0"

0 commit comments

Comments
 (0)