From 34aacf49158509925d79f626a6cccefc551c109c Mon Sep 17 00:00:00 2001
From: Audrey Hamelers <hamelers@ebi.ac.uk>
Date: Thu, 10 Jun 2021 13:30:36 +0100
Subject: [PATCH] remove default graphQL typename, explicitly request for
 article IDs

---
 app/app.jsx                                      |  1 +
 app/components/activity/MetaEdit.jsx             | 10 +---------
 app/components/dashboard/operations.js           |  1 +
 app/components/operations.js                     |  1 +
 app/components/submission-wizard/CreatePage.jsx  | 10 +---------
 .../submission-wizard/EditFundingAccess.jsx      | 16 +---------------
 app/components/submission-wizard/operations.js   |  1 +
 7 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/app/app.jsx b/app/app.jsx
index eea757803..f3666e5ca 100755
--- a/app/app.jsx
+++ b/app/app.jsx
@@ -16,6 +16,7 @@ import './assets/favicon.ico'
 
 const makeConfig = config => {
   config.cache = new InMemoryCache({
+    addTypename: false,
     typePolicies: {
       ArticleId: {
         keyFields: ['pubIdType', 'id'],
diff --git a/app/components/activity/MetaEdit.jsx b/app/components/activity/MetaEdit.jsx
index 3147785cc..b22a44af3 100644
--- a/app/components/activity/MetaEdit.jsx
+++ b/app/components/activity/MetaEdit.jsx
@@ -1,5 +1,4 @@
 import React from 'react'
-import { omit } from 'lodash'
 import { withTheme } from 'styled-components'
 import { Button } from '@pubsweet/ui'
 import { Portal, Buttons, CloseModal } from '../ui'
@@ -32,14 +31,7 @@ const MetaEdit = withTheme(
     ...props
   }) => {
     const { meta } = manuscript
-    const { fundingGroup: grants, releaseDelay, notes } = meta
-    const fundingGroup = grants
-      ? grants.map(g => {
-          const n = omit(g, '__typename')
-          n.pi = omit(g.pi, '__typename')
-          return n
-        })
-      : []
+    const { fundingGroup = [], releaseDelay, notes } = meta
 
     if (toEdit === 'dupes' && duplicates) {
       return (
diff --git a/app/components/dashboard/operations.js b/app/components/dashboard/operations.js
index 05ab37b1e..5e152610a 100644
--- a/app/components/dashboard/operations.js
+++ b/app/components/dashboard/operations.js
@@ -71,6 +71,7 @@ const DashboardFragment = gql`
       articleIds {
         pubIdType
         id
+        __typename
       }
       publicationDates {
         type
diff --git a/app/components/operations.js b/app/components/operations.js
index eb3e6ff06..26be0a298 100644
--- a/app/components/operations.js
+++ b/app/components/operations.js
@@ -64,6 +64,7 @@ export const ManuscriptFragment = gql`
       articleIds {
         pubIdType
         id
+        __typename
       }
       publicationDates {
         type
diff --git a/app/components/submission-wizard/CreatePage.jsx b/app/components/submission-wizard/CreatePage.jsx
index c5c5c7c4d..6096ff9e3 100755
--- a/app/components/submission-wizard/CreatePage.jsx
+++ b/app/components/submission-wizard/CreatePage.jsx
@@ -1,7 +1,6 @@
 import React from 'react'
 import { withRouter } from 'react-router'
 import { Query } from 'react-apollo'
-import { omit } from 'lodash'
 import { createBrowserHistory } from 'history'
 import styled, { createGlobalStyle } from 'styled-components'
 import { th } from '@pubsweet/ui-toolkit'
@@ -229,7 +228,7 @@ class Created extends React.Component {
     const { manuscript, history, changeNote, deleteNote, newNote } = this.props
     const { meta, journal, files: allfiles, teams, organization } = manuscript
     const preprint = organization.name === 'Europe PMC Preprints'
-    const { notes, fundingGroup: grants, articleIds } = meta
+    const { notes, fundingGroup = [], articleIds } = meta
     const files = allfiles
       ? allfiles.filter(
           file =>
@@ -239,13 +238,6 @@ class Created extends React.Component {
         )
       : []
     const pdfSend = allfiles && allfiles.find(f => f.type === 'pdf4load')
-    const fundingGroup = grants
-      ? grants.map(g => {
-          const n = omit(g, '__typename')
-          n.pi = omit(g.pi, '__typename')
-          return n
-        })
-      : []
     const reviewerNote = notes
       ? notes.find(n => n.notesType === 'selectedReviewer')
       : null
diff --git a/app/components/submission-wizard/EditFundingAccess.jsx b/app/components/submission-wizard/EditFundingAccess.jsx
index 23140f8de..89ab1c9d9 100644
--- a/app/components/submission-wizard/EditFundingAccess.jsx
+++ b/app/components/submission-wizard/EditFundingAccess.jsx
@@ -1,5 +1,4 @@
 import React from 'react'
-import { omit } from 'lodash'
 import styled from 'styled-components'
 import { th } from '@pubsweet/ui-toolkit'
 import { Button, Steps } from '@pubsweet/ui'
@@ -103,20 +102,7 @@ class EditFundingAccess extends React.Component {
       currentUser,
     } = this.props
     const { journal, meta, status } = manuscript
-    const {
-      articleIds,
-      releaseDelay,
-      title,
-      fundingGroup: grants,
-      notes,
-    } = meta
-    const fundingGroup = grants
-      ? grants.map(g => {
-          const n = omit(g, '__typename')
-          n.pi = omit(g.pi, '__typename')
-          return n
-        })
-      : []
+    const { articleIds, releaseDelay, title, fundingGroup = [], notes } = meta
     const planS = notes && notes.find(n => n.notesType === 'planS')
     const pmid = articleIds && articleIds.find(aid => aid.pubIdType === 'pmid')
     const pmcid =
diff --git a/app/components/submission-wizard/operations.js b/app/components/submission-wizard/operations.js
index 6c4df92e3..90bd33ecd 100644
--- a/app/components/submission-wizard/operations.js
+++ b/app/components/submission-wizard/operations.js
@@ -22,6 +22,7 @@ export const CREATE_MANUSCRIPT = gql`
           articleIds {
             pubIdType
             id
+            __typename
           }
           publicationDates {
             type
-- 
GitLab