Skip to content

Conversation

@htranho
Copy link

@htranho htranho commented Jan 26, 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 revision of a collection by its concept ID and revision ID.

What is the Solution?

The solution involves modifying the Collection concept class and related resolvers to handle revision-specific queries. Key changes include:

  1. Adding methods to fetch and parse revision-specific data from CMR.
  2. Implementing logic to merge meta fields from all revisions when necessary.
  3. Adding checks to prevent certain fields (revisions, relatedCollections, duplicateCollections) from being queried when requesting a specific revision.
  4. Updating the CollectionInput type to include a revisionId parameter.

What areas of the application does this impact?

This change impacts several areas of the application:

  1. src/cmr/concepts/concept.js: Major updates to the Concept class to support revision-specific queries.
  2. src/resolvers/collection.js: Updates to collection resolvers to handle revision-specific queries and add appropriate error checks.
  3. src/types/collection.graphql: Addition of revisionId to the CollectionInput type.
  4. src/resolvers/__tests__/collection.test.js: New tests added to cover the new functionality and error cases.

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:
    query {
      collection(params: { conceptId: "C100000-EDSC", revisionId: "2" }) {
        conceptId
        revisionId
        entryTitle
        revisionDate
      }
    }
  4. Verify that the correct revision is returned with the requested fields.
  5. Test error cases by requesting fields that are not allowed for specific revisions:
    query {
      collection(params: { conceptId: "C100000-EDSC", revisionId: "2" }) {
        conceptId
        revisionId
        revisions {
          count
        }
      }
    }
  6. Verify that appropriate error messages are returned.
  7. 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 January 26, 2026 23:11
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f4f11ce) to head (41ef594).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #177   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          115       115           
  Lines         2694      2762   +68     
  Branches       328       343   +15     
=========================================
+ Hits          2694      2762   +68     

☔ 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.

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