Skip to content

Commit

Permalink
EDSC-3951: Update GraphQL queries to use new params parameter objec…
Browse files Browse the repository at this point in the history
…ts (#1706)

* EDSC-3951: Update GraphQL queries to use new `params` parameter objects

* Linting

* Updated mock

* linting

* Updates for unit tests

* Updated test value.

* Additional quotes.

* Updates Jan 17

* remove it.only from cypress test

* fixes for cypress.

* lint

* Update for playwright

* Update playwright projetions query

* Remove console statements.

* EDSC-3951: Fix granules link calls

---------

Co-authored-by: Ed Olivares <34591886+eudoroolivares2016@users.noreply.github.com>
  • Loading branch information
Bccorb and eudoroolivares2016 authored Jan 30, 2024
1 parent f490989 commit ee357c2
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 175 deletions.
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 ) {
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) {
collections (params: $params) {
cursor
items {
provider
Expand Down
Loading

0 comments on commit ee357c2

Please sign in to comment.