Upgrade to work with @dmptool/types v4.0.0 - #14
Conversation
… getPlanWorkflow function
|
This deserves another look @jupiter007 I moved much of the logic to the Apollo server's new The API is now simply converting incoming maDMP JSON into GraphQL queries. |
jupiter007
left a comment
There was a problem hiding this comment.
Looks good overall. I just had a few comments.
I guess it makes sense to consolidate mutation and query data into one "entire plan".
One thing I noticed is that you can simplify plan.graphql to use fragments. If you do that, you can simplify the Plan.fromGraphQL method.
Also, do we need to update the README.md file?
| } | ||
| } | ||
|
|
||
| query PlanByDmpId($dmpId: String!) { |
There was a problem hiding this comment.
I think you can use fragment here to simplify this. The PlanByDmpId and PlanByAlternateIdentifier return the exact same data. So you can extract all the fields into a fragment like below, and then future changes can happen in one place. Also, this would simplify the Plan.toGraphQL.
fragment PlanDetails on Plan {
id
dmpId
title
visibility
status
created
createdById
modified
modifiedById
registered
project {
id
title
abstractText
startDate
endDate
isTestProject
researchDomain {
id
uri
}
members {
id
isPrimaryContact
affiliation { uri }
givenName
surName
orcid
email
memberRoles { id uri }
}
fundings {
id
affiliation { uri }
status
funderProjectNumber
funderOpportunityNumber
grantId
}
}
members {
projectMember { id }
memberRoles { id uri }
}
fundings {
id
projectFunding { id }
}
answers {
id
versionedSection { id }
versionedQuestion { id }
json
}
versionedTemplate {
id
name
description
version
template { id }
versionedSections {
id
name
displayOrder
versionedQuestions {
id
questionText
json
}
}
}
alternateIdentifiers {
id
alternateIdentifier
}
}
and then
query PlanByDmpId($dmpId: String!) {
planByDMPId(dmpId: $dmpId) {
...PlanDetails
}
}
query PlanByAlternateIdentifier($alternateIdentifier: String!) {
planByAlternateIdentifier(alternateIdentifier: $alternateIdentifier) {
...PlanDetails
}
}
| error: FastifyError | Error, | ||
| ): FastifyReply => { | ||
|
|
||
| console.log('ERROR', error) |
There was a problem hiding this comment.
Did you mean to leave this console.log here?
| } | ||
|
|
||
| // If the maDMP record could not be generated or retrieved, we need to bail out | ||
| if (!maDMP || !maDMP.dmp) { |
There was a problem hiding this comment.
Do we need to throw the ERROR_CODE_INTERNAL_SERVER here:
if (!maDMP || !maDMP.dmp) {
request.log.error({ dmpId }, "Unable to generate narrative for DMP");
throw newFastifyError(ERROR_CODE_INTERNAL_SERVER, ERROR_MSG_INTERNAL_SERVER);
}
It looks like if we return undefined to createPlanWorkflow, which calls this, then it returns an ERROR_CODE_INVALID_DMP. Is that expected?
| - The [RDA Common Standard](https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard) is a community standard for machine-actionable DMPs. | ||
| - The [DMP Tool extended format](https://github.com/CDLUC3/dmptool-types/blob/main/schemas/dmptoolDmp.schema.json) combines the RDA Common Standard with [properties specific to the DMP Tool](https://github.com/CDLUC3/dmptool-types/blob/main/schemas/dmpExtension.schema.json). | ||
|
|
||
| You can switch between these two format for each endpoint by scrolling down to the **Responses** section of the endpoint and changing the **Media type** dropdown underneath the \`200\` HTTP status code. Changing this dropdown automatically updates the \`Accept\` header sent with your request. |
There was a problem hiding this comment.
L25: minor - "format" should be "formats"
|
|
||
| export const DEFAULT_LANGUAGE = 'en-US' as const; | ||
|
|
||
| export const LanguageMapThreeToFive = { |
There was a problem hiding this comment.
It might be helpful to add some comments on what the LanguageMapThreeToFive and LanguageMapFiveToThree are for.
Upgrade to v4.0.0 of
@dmptool/typesand v2.1.6 of@dmptool/utils