From 7b05bbfc1c9f4c06b8591625d3c14e05e2fe197e Mon Sep 17 00:00:00 2001 From: Jure Triglav <juretriglav@gmail.com> Date: Wed, 29 Jul 2020 11:14:29 +0200 Subject: [PATCH] fix: add an ID to the ManuscriptMeta object to enable cache merging --- app/Root.jsx | 3 +++ .../component-dashboard/src/graphql/mutations/index.js | 1 + .../component-dashboard/src/graphql/queries/index.js | 1 + app/components/component-manuscripts/src/Manuscripts.jsx | 2 ++ app/components/component-submit/src/components/SubmitPage.js | 1 + app/components/component-submit/src/upload.js | 1 + .../src/components/graphql/queries/index.js | 1 + server/model-manuscript/src/graphql.js | 4 ++++ 8 files changed, 14 insertions(+) diff --git a/app/Root.jsx b/app/Root.jsx index 339ec005f0..1cbe6be395 100644 --- a/app/Root.jsx +++ b/app/Root.jsx @@ -78,6 +78,9 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => { link, cache: new InMemoryCache({ typePolicies: { + ManuscriptMeta: { + keyFields: ['manuscriptId'], + }, Manuscript: { fields: { _currentRoles: { diff --git a/app/components/component-dashboard/src/graphql/mutations/index.js b/app/components/component-dashboard/src/graphql/mutations/index.js index 9829814164..019eceb78b 100644 --- a/app/components/component-dashboard/src/graphql/mutations/index.js +++ b/app/components/component-dashboard/src/graphql/mutations/index.js @@ -74,6 +74,7 @@ export default { } } meta { + manuscriptId title declarations { openData diff --git a/app/components/component-dashboard/src/graphql/queries/index.js b/app/components/component-dashboard/src/graphql/queries/index.js index 1b45a6149a..14952c20c8 100644 --- a/app/components/component-dashboard/src/graphql/queries/index.js +++ b/app/components/component-dashboard/src/graphql/queries/index.js @@ -43,6 +43,7 @@ export default { } status meta { + manuscriptId title declarations { openData diff --git a/app/components/component-manuscripts/src/Manuscripts.jsx b/app/components/component-manuscripts/src/Manuscripts.jsx index 5d62f1d99c..b07e1bd23d 100644 --- a/app/components/component-manuscripts/src/Manuscripts.jsx +++ b/app/components/component-manuscripts/src/Manuscripts.jsx @@ -33,6 +33,7 @@ const GET_MANUSCRIPTS = gql` manuscripts { id meta { + manuscriptId title } created @@ -97,6 +98,7 @@ const Manuscripts = () => { offset: (page - 1) * limit, limit, }, + fetchPolicy: 'network-only', }) if (loading) return <Spinner /> diff --git a/app/components/component-submit/src/components/SubmitPage.js b/app/components/component-submit/src/components/SubmitPage.js index 5c6ce3ed5b..c510504b92 100644 --- a/app/components/component-submit/src/components/SubmitPage.js +++ b/app/components/component-submit/src/components/SubmitPage.js @@ -47,6 +47,7 @@ const fragmentFields = ` decision status meta { + manuscriptId title abstract declarations { diff --git a/app/components/component-submit/src/upload.js b/app/components/component-submit/src/upload.js index 2f06bf098e..3a733062e9 100644 --- a/app/components/component-submit/src/upload.js +++ b/app/components/component-submit/src/upload.js @@ -59,6 +59,7 @@ const createManuscriptMutation = gql` } } meta { + manuscriptId title declarations { openData diff --git a/app/components/component-teams-manager/src/components/graphql/queries/index.js b/app/components/component-teams-manager/src/components/graphql/queries/index.js index b522b5e937..5f31211a9a 100644 --- a/app/components/component-teams-manager/src/components/graphql/queries/index.js +++ b/app/components/component-teams-manager/src/components/graphql/queries/index.js @@ -4,6 +4,7 @@ const fragmentFields = ` id created meta { + manuscriptId title } ` diff --git a/server/model-manuscript/src/graphql.js b/server/model-manuscript/src/graphql.js index 39b107a3d1..cc598e633a 100644 --- a/server/model-manuscript/src/graphql.js +++ b/server/model-manuscript/src/graphql.js @@ -308,6 +308,9 @@ const resolvers = { await ctx.models.Manuscript.query().findById(parent.id) ).$relatedQuery('teams') }, + meta(parent) { + return { ...parent.meta, manuscriptId: parent.id } + }, }, ManuscriptVersion: { submission(parent) { @@ -434,6 +437,7 @@ const typeDefs = ` publicationDates: [MetaDate] notes: [Note] keywords: String + manuscriptId: ID } type ArticleId { -- GitLab