Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade graphql packages dependencies #6614

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"data-generator-retail": "^3.9.0",
"fakerest": "^3.0.0",
"fetch-mock": "~6.3.0",
"json-graphql-server": "~2.1.3",
"json-graphql-server": "~2.3.0",
"proxy-polyfill": "^0.3.0",
"ra-data-fakerest": "^3.9.0",
"ra-data-graphql-simple": "^3.9.0",
Expand Down
6 changes: 4 additions & 2 deletions examples/demo/src/dataProvider/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloQueryResult } from 'apollo-client';
import { ApolloQueryResult } from '@apollo/client';
import buildApolloClient, {
buildQuery as buildQueryFactory,
} from 'ra-data-graphql-simple';
Expand Down Expand Up @@ -55,7 +55,9 @@ const customBuildQuery = (
if (type === DELETE) {
return {
query: gql`mutation remove${resource}($id: ID!) {
remove${resource}(id: $id)
remove${resource}(id: $id) {
id
}
}`,
variables: { id: params.id },
parseResponse: ({ data }: ApolloQueryResult<any>) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/ra-data-graphql-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@
},
"dependencies": {
"graphql-ast-types-browser": "~1.0.2",
"graphql-tag": "^2.10.1",
"lodash": "~4.17.5",
"pluralize": "~7.0.0",
"ra-data-graphql": "^3.11.4"
},
"peerDependencies": {
"graphql": "^14.1.1",
"graphql": "^15.6.0",
"ra-core": "^3.9.0"
},
"devDependencies": {
"cross-env": "^5.2.0",
"graphql": "^14.1.1",
"graphql": "^15.6.0",
"rimraf": "^2.6.3"
}
}
2 changes: 1 addition & 1 deletion packages/ra-data-graphql-simple/src/buildQuery.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import gql from 'graphql-tag';
import { gql } from '@apollo/client';
import { buildQueryFactory } from './buildQuery';

describe('buildQuery', () => {
Expand Down
8 changes: 3 additions & 5 deletions packages/ra-data-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@
"watch": "tsc --outDir esm --module es2015 --watch"
},
"dependencies": {
"apollo-client": "^2.6.3",
"apollo-client-preset": "^1.0.8",
"graphql-tag": "^2.10.1",
"@apollo/client": "^3.3.19",
"lodash": "~4.17.5",
"pluralize": "~7.0.0"
},
"peerDependencies": {
"graphql": "^14.1.1",
"graphql": "^15.6.0",
"ra-core": "^3.9.0"
},
"devDependencies": {
"cross-env": "^5.2.0",
"graphql": "^14.1.1",
"graphql": "^15.6.0",
"rimraf": "^2.6.3"
}
}
19 changes: 2 additions & 17 deletions packages/ra-data-graphql/src/buildApolloClient.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { ApolloClient } from 'apollo-client';
import {
HttpLink,
InMemoryCache,
IntrospectionFragmentMatcher,
} from 'apollo-client-preset';
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';

export default options => {
if (!options) {
Expand All @@ -14,22 +9,12 @@ export default options => {
let finalLink = link;
let finalCache = cache;

// Create an empty fragment matcher
// See: https://github.com/apollographql/apollo-client/issues/3397#issuecomment-421433032
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData: {
__schema: {
types: [],
},
},
});

if (!link && uri) {
finalLink = new HttpLink({ uri });
}

if (!cache) {
finalCache = new InMemoryCache({ fragmentMatcher }).restore({});
finalCache = new InMemoryCache().restore({});
}

return new ApolloClient({
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-data-graphql/src/introspection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getIntrospectionQuery } from 'graphql';
import gql from 'graphql-tag';
import { gql } from '@apollo/client';
import { GET_LIST, GET_ONE } from 'ra-core';

import { ALL_TYPES } from './constants';
Expand Down
Loading