Skip to content

GQL-118: Add support for retrieving a collection revision#182

Merged
htranho merged 22 commits intomainfrom
GQL-118-UMM
Apr 8, 2026
Merged

GQL-118: Add support for retrieving a collection revision#182
htranho merged 22 commits intomainfrom
GQL-118-UMM

Conversation

@htranho
Copy link
Copy Markdown
Contributor

@htranho htranho commented Mar 18, 2026

Overview

What is the feature?

This feature adds support for fetching specific revisions of collections in the GraphQL API. It allows querying a particular historical revision of a collection by its concept ID and revision ID.

What is the Solution?

Route all queries for revisions exclusively through the UMM endpoint, which does support historical revisions.

Key changes include:

  1. src/cmr/concepts/concept.js:
    Added support for revisionId in the fetchUmm method.
    Modified the parseUmm method to filter out items that don't match the requested revisionId.
    Added logic to update the item count when filtering by revisionId.

  2. src/resolvers/tests/collection.test.js:
    Added new tests for retrieving collections by revisionId.
    Included tests for both successful retrieval and cases where the specified revision doesn't exist.

  3. src/types/collection.graphql:
    Added revisionId as a new input parameter in the CollectionInput type.

  4. src/utils/tests/parseRequestedFields.test.js:
    Added a new test case for when revisionId is provided, ensuring all keys are moved to ummKeys.

  5. src/utils/cmrQuery.js:
    Modified to support the all_revisions parameter when options.allRevisions is set.

  6. src/utils/parseRequestedFields.js:
    Updated to handle the revisionId parameter.
    Modified logic to use UMM endpoint exclusively when revisionId is present.

  7. src/utils/umm/collectionKeyMap.json:
    Added 'provider' to the list of shared keys.
    Mapped 'provider' to 'meta.provider-id' in the UMM key mappings.

What areas of the application does this impact?

Query for single collection: revisionId added as new parameter to CollectionInput

Testing

Reproduction steps

  • Environment for testing: Local development environment
  • Collection to test with: Any collection with multiple revisions in CMR
  1. Start the GraphQL server locally.
  2. Use a GraphQL client (e.g., GraphQL Playground) to send queries.
  3. Test querying a specific revision of a collection, example:
    query Collection($params: CollectionInput) {
         collection(params: $params) {
             conceptId
             shortName
             revisionId
             revisionDate
             associationDetails
         }
     }
     with
     {
         "params": {
             "conceptId": "C1200237617-MMT_1",
             "revisionId": "23"
         }
     }
  • Use MMT to revome or add Variable or any other concept type's associations to this collection. check if changes seen in graphql.
  • Request all collection fields. Known error in main branch and also this branch is the field generateVariableDrafts.
  1. Verify that the correct revision is returned with the requested fields.
  2. Test error cases by requesting fields that are not allowed for specific revisions:
    query {
      collection(params: { conceptId: "C1200237617-MMT_1", revisionId: "23" }) {
        conceptId
        revisionId
        revisions {
          count
        }
      }
    }
  3. Verify that appropriate error messages are returned.
  4. Test fetching a collection without specifying a revision ID to ensure backward compatibility.

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@htranho htranho marked this pull request as draft March 18, 2026 23:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (aa8f5f7) to head (611ad91).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #182   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          115       115           
  Lines         2706      2719   +13     
  Branches       330       335    +5     
=========================================
+ Hits          2706      2719   +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/datasources/collection.js Outdated
Comment thread src/resolvers/collection.js Outdated
Comment thread src/resolvers/collection.js Outdated
Comment thread src/datasources/collection.js Outdated
Comment thread src/types/collection.graphql Outdated
Comment thread src/utils/umm/collectionKeyMap.json
Comment thread src/datasources/collection.js Outdated
Comment thread src/datasources/collection.js Outdated
Comment thread src/datasources/collection.js Outdated
Comment thread src/resolvers/collection.js Outdated
Comment thread src/resolvers/collection.js Outdated
Comment thread src/resolvers/collection.js Outdated
Comment thread src/utils/parseRequestedFields.js Outdated
Comment thread src/utils/parseRequestedFields.js Outdated
@htranho htranho marked this pull request as ready for review March 23, 2026 21:31
Comment thread src/utils/umm/collectionKeyMap.json Outdated
Copy link
Copy Markdown
Contributor

@macrouch macrouch left a comment

Choose a reason for hiding this comment

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

I'm confused about how we are handling json fields. In my testing I tried added boxes to my request and I just got null, but when I add the revisions field I get a CMR error. We had talked during one iteration of this ticket that we could let users know fields weren't supported. Did we want to do that or are we just returning null?

It also seems like the revisions field is broken. Even without including the revisionId parameter I still get back a CMR error when requesting the revisions field ("The mime type [application/json] is not supported when all_revisions = true.") which could be confusing for a user

Comment thread src/resolvers/__tests__/collection.test.js Outdated
Comment thread src/resolvers/__tests__/collection.test.js
Comment thread src/utils/parseRequestedFields.js Outdated
Comment thread src/utils/__tests__/parseRequestedFields.test.js Outdated
Comment thread src/utils/cmrQuery.js Outdated
Comment thread src/cmr/concepts/concept.js Outdated
@eudoroolivares2016
Copy link
Copy Markdown
Contributor

Did some integration testing on this against my local MMT hooked to SIT while this was up. Obviously that is its own effort but, in principle we can use this API to fix that issue in MMT

Comment thread src/utils/umm/collectionKeyMap.json Outdated
Comment thread src/utils/umm/collectionKeyMap.json
Comment thread src/utils/parseRequestedFields.js Outdated
@htranho htranho changed the title GQL-118a: Add support for retrieving a collection revision GQL-118: Add support for retrieving a collection revision Apr 7, 2026
@htranho htranho merged commit afb7fef into main Apr 8, 2026
9 checks passed
@htranho htranho deleted the GQL-118-UMM branch April 8, 2026 14:49
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.

4 participants