Skip to content

Commit

Permalink
update graphql codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
nialexsan committed Sep 17, 2024
1 parent 7d3a840 commit b78a95b
Show file tree
Hide file tree
Showing 8 changed files with 2,669 additions and 2,999 deletions.
4,306 changes: 2,081 additions & 2,225 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-env": "^7.19.1",
"@babel/preset-typescript": "^7.18.6",
"@graphql-codegen/cli": "^2.13.12",
"@graphql-codegen/fragment-matcher": "^1.17.8",
"@graphql-codegen/introspection": "^1.12.1",
"@graphql-codegen/typescript": "^1.12.1",
"@graphql-codegen/typescript-graphql-files-modules": "^1.17.8",
"@graphql-codegen/typescript-operations": "^1.12.1",
"@graphql-codegen/typescript-react-apollo": "^3.3.7",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/fragment-matcher": "^5.0.2",
"@graphql-codegen/introspection": "^4.0.3",
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-graphql-files-modules": "^3.0.0",
"@graphql-codegen/typescript-operations": "^4.2.3",
"@graphql-codegen/typescript-react-apollo": "^4.3.2",
"@sentry/types": "^7.44.0",
"@types/file-saver": "^2.0.5",
"@types/isomorphic-fetch": "0.0.36",
Expand Down
49 changes: 31 additions & 18 deletions src/api/apollo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ApolloLink,
HttpLink,
gql,
makeVar,
} from '@apollo/client';
import DebounceLink from 'apollo-link-debounce';
import SerializingLink from 'apollo-link-serialize';
Expand All @@ -17,7 +18,20 @@ import { GraphQLErrorExtensions, GraphQLFormattedError } from 'graphql';
const PLAYGROUND_API = process.env.PLAYGROUND_API;
const DEFAULT_DEBOUNCE_TIMEOUT = 1200; // Debounce time in ms
const { detect } = require('detect-browser');
const cache = new InMemoryCache();
export const errorMessageVar = makeVar('');
const cache = new InMemoryCache({
typePolicies: {
Query: {
fields: {
errorMessage: {
read() {
return errorMessageVar();
},
},
},
},
},
});
const client = new ApolloClient({
cache: cache,
link: ApolloLink.from([
Expand Down Expand Up @@ -90,31 +104,30 @@ const client = new ApolloClient({
cache.writeQuery({
query: gql`
query InitValues {
localProject
activeProjectId
activeProject
errorMessage
cachedExecutionResults {
id
${ResultType.Transaction}
${ResultType.Script}
${ResultType.Contract}
}
}
`,
data: {
localProject: null,
activeProjectId: null,
activeProject: false,
errorMessage: '',
cachedExecutionResults: {
id: '0',
__typename: 'ExecutionResults',
[ResultType.Transaction]: [],
[ResultType.Script]: [],
[ResultType.Contract]: [],
},
},
});

cache.writeFragment({
id: 'ExecutionResults:0',
fragment: gql`
fragment ExecutionResultFields on ExecutionResult {
${ResultType.Transaction}
${ResultType.Script}
${ResultType.Contract}
}
`,
data: {
[ResultType.Transaction]: [],
[ResultType.Script]: [],
[ResultType.Contract]: [],
}
})

export default client;
Loading

0 comments on commit b78a95b

Please sign in to comment.