Skip to content

Upgrade to work with @dmptool/types v4.0.0 - #14

Open
briri wants to merge 8 commits into
developmentfrom
bug/commonStandardId
Open

Upgrade to work with @dmptool/types v4.0.0#14
briri wants to merge 8 commits into
developmentfrom
bug/commonStandardId

Conversation

@briri

@briri briri commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Upgrade to v4.0.0 of @dmptool/types and v2.1.6 of @dmptool/utils

@briri
briri changed the base branch from main to development July 13, 2026 15:14
@briri
briri requested a review from jupiter007 July 13, 2026 15:14

@jupiter007 jupiter007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@briri

briri commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

This deserves another look @jupiter007

I moved much of the logic to the Apollo server's new entirePlan resolvers to take advantage of the MySQL transactions.

The API is now simply converting incoming maDMP JSON into GraphQL queries.

@jupiter007 jupiter007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
  }
}

Comment thread src/handlers/error.ts
error: FastifyError | Error,
): FastifyReply => {

console.log('ERROR', error)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread src/plugins/v3/swagger.ts
- 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L25: minor - "format" should be "formats"

Comment thread src/utils.ts

export const DEFAULT_LANGUAGE = 'en-US' as const;

export const LanguageMapThreeToFive = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to add some comments on what the LanguageMapThreeToFive and LanguageMapFiveToThree are for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants