Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDSC-3951: Update GraphQL queries to use new params parameter objects #1706

Merged
merged 16 commits into from
Jan 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Path /search/granules/granule-details', () => {
})
}

if (JSON.stringify(req.body) === '{"query":"\\n query GetGranule(\\n $id: String!\\n ) {\\n granule(\\n conceptId: $id\\n ) {\\n granuleUr\\n granuleSize\\n title\\n onlineAccessFlag\\n dayNightFlag\\n timeStart\\n timeEnd\\n dataCenter\\n originalFormat\\n conceptId\\n collectionConceptId\\n spatialExtent\\n temporalExtent\\n relatedUrls\\n dataGranule\\n measuredParameters\\n providerDates\\n }\\n }","variables":{"id":"G1287941210-ASF"}}') {
if (JSON.stringify(req.body) === `{"query":"\\n query GetGranule(\\n $params: GranuleInput\\n ) {\\n granule(\\n params: $params\\n ) {\\n granuleUr\\n granuleSize\\n title\\n onlineAccessFlag\\n dayNightFlag\\n timeStart\\n timeEnd\\n dataCenter\\n originalFormat\\n conceptId\\n collectionConceptId\\n spatialExtent\\n temporalExtent\\n relatedUrls\\n dataGranule\\n measuredParameters\\n providerDates\\n }\\n }","variables":{"params":{"conceptId":"${granuleId}"}}}`) {
req.alias = 'graphQlGranuleQuery'
req.reply({
body: getGranuleGraphQlBody,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/paths/search/granules/granules.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ describe('Path /search/granules', () => {
})
}

if (JSON.stringify(req.body) === '{"query":"\\n query GetGranule(\\n $id: String!\\n ) {\\n granule(\\n conceptId: $id\\n ) {\\n granuleUr\\n granuleSize\\n title\\n onlineAccessFlag\\n dayNightFlag\\n timeStart\\n timeEnd\\n dataCenter\\n originalFormat\\n conceptId\\n collectionConceptId\\n spatialExtent\\n temporalExtent\\n relatedUrls\\n dataGranule\\n measuredParameters\\n providerDates\\n }\\n }","variables":{"id":"G2058417402-LPDAAC_ECS"}}') {
if (JSON.stringify(req.body) === '{"query":"\\n query GetGranule(\\n $params: GranuleInput\\n ) {\\n granule(\\n params: $params\\n ) {\\n granuleUr\\n granuleSize\\n title\\n onlineAccessFlag\\n dayNightFlag\\n timeStart\\n timeEnd\\n dataCenter\\n originalFormat\\n conceptId\\n collectionConceptId\\n spatialExtent\\n temporalExtent\\n relatedUrls\\n dataGranule\\n measuredParameters\\n providerDates\\n }\\n }","variables":{"params":{"conceptId":"G2058417402-LPDAAC_ECS"}}}') {
req.alias = 'graphQlGranuleQuery'
req.reply({
body: focusedGranuleGranuleGraphQlBody,
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/graphQlGetCollection.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cypress/support/graphQlGetCollections.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 10 additions & 60 deletions serverless/src/retrieveGranuleLinks/fetchCmrLinks.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,13 @@
import axios from 'axios'
import camelcaseKeys from 'camelcase-keys'

import { prepareGranuleAccessParams } from '../../../sharedUtils/prepareGranuleAccessParams'
import { getApplicationConfig, getEarthdataConfig } from '../../../sharedUtils/config'
import { getDownloadUrls } from '../../../sharedUtils/getDownloadUrls'
import { getS3Urls } from '../../../sharedUtils/getS3Urls'
import { getBrowseUrls } from '../../../sharedUtils/getBrowseUrls'

const granulesGraphQlQuery = `
query GetGranuleLinks(
$boundingBox: [String]
$browseOnly: Boolean
$circle: [String]
$cloudCover: JSON
$collectionConceptId: String
$conceptId: [String]
$cursor: String
$dayNightFlag: String
$equatorCrossingDate: JSON
$equatorCrossingLongitude: JSON
$exclude: JSON
$limit: Int
$line: [String]
$linkTypes: [String]
$offset: Int
$onlineOnly: Boolean
$options: JSON
$orbitNumber: JSON
$point: [String]
$polygon: [String]
$readableGranuleName: [String]
$sortKey: [String]
$temporal: String
$twoDCoordinateSystem: JSON
) {
granules(
boundingBox: $boundingBox
browseOnly: $browseOnly
circle: $circle
cloudCover: $cloudCover
collectionConceptId: $collectionConceptId
conceptId: $conceptId
cursor: $cursor
dayNightFlag: $dayNightFlag
equatorCrossingDate: $equatorCrossingDate
equatorCrossingLongitude: $equatorCrossingLongitude
exclude: $exclude
limit: $limit
line: $line
linkTypes: $linkTypes
offset: $offset
onlineOnly: $onlineOnly
options: $options
orbitNumber: $orbitNumber
point: $point
polygon: $polygon
readableGranuleName: $readableGranuleName
sortKey: $sortKey
temporal: $temporal
twoDCoordinateSystem: $twoDCoordinateSystem
) {
query GetGranuleLinks( $params: GranulesInput ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am seeing an issue on this one where we can't get the granule downloads due to this causing a 500 error. To replicate: Find a collection add some granules to project use the Download option. Normally we get the granules links on the results page but, its erroring out

granules( params: $params) {
cursor
items {
links
Expand All @@ -81,14 +29,16 @@ export const fetchCmrLinks = async ({

const graphQlUrl = `${graphQlHost}/api`

const preparedGranuleParams = camelcaseKeys(prepareGranuleAccessParams(granuleParams))
const { concept_id: conceptIdsFromParams = [] } = granuleParams

const variables = {
...preparedGranuleParams,
limit: parseInt(granuleLinksPageSize, 10),
linkTypes: linkTypes.split(','),
collectionConceptId: collectionId,
cursor
params: {
limit: parseInt(granuleLinksPageSize, 10),
linkTypes: linkTypes.split(','),
collectionConceptId: collectionId,
conceptId: conceptIdsFromParams,
cursor
}
}

const response = await axios({
Expand Down
74 changes: 2 additions & 72 deletions static/src/js/actions/exportSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,78 +132,8 @@ export const exportSearchAsStac = (format) => (dispatch, getState) => {
const graphQlRequestObject = new ExportSearchRequest(authToken, earthdataEnvironment)

const graphQuery = `
query SearchCollections(
$boundingBox: [String]
$circle: [String]
$cloudHosted: Boolean
$collectionDataType: [String]
$dataCenter: String
$dataCenterH: [String]
$facetsSize: Int
$granuleDataFormat: String
$granuleDataFormatH: [String]
$hasGranulesOrCwic: Boolean
$horizontalDataResolutionRange: [String]
$instrument: String
$instrumentH: [String]
$keyword: String
$line: [String]
$offset: Int
$options: JSON
$platform: String
$platformH: [String]
$point: [String]
$polygon: [String]
$processingLevelIdH: [String]
$project: String
$projectH: [String]
$provider: String
$scienceKeywordsH: JSON
$serviceType: [String]
$sortKey: [String]
$spatialKeyword: String
$tagKey: [String]
$temporal: String
$twoDCoordinateSystemName: [String]
$limit: Int
$cursor: String
) {
collections (
boundingBox: $boundingBox
circle: $circle
cloudHosted: $cloudHosted
collectionDataType: $collectionDataType
dataCenter: $dataCenter
dataCenterH: $dataCenterH
facetsSize: $facetsSize
granuleDataFormat: $granuleDataFormat
granuleDataFormatH: $granuleDataFormatH
hasGranulesOrCwic: $hasGranulesOrCwic
horizontalDataResolutionRange: $horizontalDataResolutionRange
instrument: $instrument
instrumentH: $instrumentH
keyword: $keyword
line: $line
offset: $offset
options: $options
platform: $platform
platformH: $platformH
point: $point
polygon: $polygon
processingLevelIdH: $processingLevelIdH
project: $project
projectH: $projectH
provider: $provider
scienceKeywordsH: $scienceKeywordsH
serviceType: $serviceType
sortKey: $sortKey
spatialKeyword: $spatialKeyword
tagKey: $tagKey
temporal: $temporal
twoDCoordinateSystemName: $twoDCoordinateSystemName
limit: $limit,
cursor: $cursor
) {
query SearchCollections($params: CollectionsInput) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function might be OBE I don't see any way to access it on the controller and its not called anywhere else

collections (params: $params) {
cursor
items {
provider
Expand Down
Loading
Loading