Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
fix(project): fix error when updating or creating a node without crea…
Browse files Browse the repository at this point in the history
…ted and modified properties
  • Loading branch information
ChristiaanScheermeijer committed Mar 12, 2021
1 parent 8cb1796 commit e4cbcb3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/transformers/createdUpdatedFieldTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ export const createdUpdatedFieldTransformer = new TransformRootFields((operation
const next = field.resolve

field.resolve = (object, params, context, info) => {
const returnTypeFields = info.returnType.getFields()
const hasModifiedField = !!returnTypeFields['modified']
const hasCreatedField = !!returnTypeFields['created']

// returnType is missing either the created or modified fields
if (!hasModifiedField || !hasCreatedField) {
return next(object, params, context, info)
}

info.fieldNodes = info.fieldNodes.map(fieldNode => {
const createdIndex = fieldNode.arguments.findIndex(argument => argument.name.value === 'created')
const modifiedIndex = fieldNode.arguments.findIndex(argument => argument.name.value === 'modified')
Expand Down

0 comments on commit e4cbcb3

Please sign in to comment.