3

Hi I have been trying below graphql query to fetch tridion docs content but it throws null pointer exception, could someone please suggest me what is wrong here

query items($first: Int, $after: String, $inputItemFilter: InputItemFilter!, $inputSortParam: InputSortParam, $contextData: [InputClaimValue!]) {
    items(first: $first, after: $after, filter: $inputItemFilter, sort: $inputSortParam, contextData: $contextData) {
        edges {
            cursor
            node {
                ...ItemFields               

            }       
        }
    }
}fragment ItemFields on Item {
    id
    itemId
    itemType
    namespaceId
    owningPublicationId
    publicationId
    title
    lastPublishDate
    creationDate
    initialPublishDate
    updatedDate   
    ...CustomMetaFields
}
fragment CustomMetaFields on Item {
  customMetas {
    edges {
      node {
          id
          itemId
          key
          namespaceId
          publicationId
          value
          valueType    
      }
    }
  }
}

variables passed as

{
    "after": null,
    "inputItemFilter": {
        "and": [{
            "and": null,
            "customMeta": {
                "key": "ishversionref.object.id",
                "scope": null,
                "value": "35686",
                "valueType": null
            },
            "itemTypes": null,
            "keyword": null,
            "namespaceIds": [2],
            "or": null,
            "publicationIds": null,
            "schema": null
        }],
        "customMeta": {
            "key": "publicationtitle.generated.value",
            "scope": null,
            "value": "content_test",
            "valueType": null
        },
        "itemTypes": null,
        "keyword": null,
        "namespaceIds": [2],
        "or": null,
        "publicationIds": null,
        "schema": null
    },
    "inputSortParam": {
        "order": "Ascending",
        "sortBy": "ITEM_ID"
    },
    "first": 0,
    "contextData": [{
        "type": "STRING",
        "uri": "dxa:modelservice:model:type",
        "value": "R2"
    }, {
        "type": "STRING",
        "uri": "dxa:modelservice:content:type",
        "value": "MODEL"
    }, {
        "type": "BOOLEAN",
        "uri": "dxa:modelservice:model:entity:relativelinks",
        "value": "true"
    }, {
        "type": "STRING",
        "uri": "taf:request:parameters",
        "value": "{\"CONTENT_LENGTH\":[\"-1\"],\"QUERY_STRING\":[null],\"CONTENT_TYPE\":[null],\"PATH_INFO\":[\"/\"]}"
    }, {
        "type": "BOOLEAN",
        "uri": "taf:tcdl:render:link:relative",
        "value": "true"
    }]
}

error which is coming on response

2020-04-20 06:46:40,039 ERROR CustomDataFetcherExceptionHandler - Exception while fetching data (/items) : java.lang.NullPointerException
java.util.concurrent.CompletionException: java.lang.NullPointerException
    at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
    at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source)
    at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
    at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
    at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.NullPointerException: null
    at com.sdl.delivery.content.dataloaders.broker.builder.BrokerQueryBuilder.getCustomMetaValueByType(BrokerQueryBuilder.java:349)
    at com.sdl.delivery.content.dataloaders.broker.builder.BrokerQueryBuilder.buildCustomMetaCriteria(BrokerQueryBuilder.java:244)
    at com.sdl.delivery.content.dataloaders.broker.builder.BrokerQueryBuilder.buildCriteria(BrokerQueryBuilder.java:210)
    at com.sdl.delivery.content.dataloaders.broker.builder.BrokerQueryBuilder.buildQuery(BrokerQueryBuilder.java:186)
    at com.sdl.delivery.content.dataloaders.broker.builder.BrokerQueryBuilder.buildQueryWithConditions(BrokerQueryBuilder.java:160)
    at com.sdl.delivery.content.dataloaders.broker.builder.BrokerQueryBuilder.buildQueryWithSort(BrokerQueryBuilder.java:155)
    at com.sdl.delivery.content.dataloaders.broker.BrokerItemsCriteriaDataLoader.getItemsByAndSort(BrokerItemsCriteriaDataLoader.java:106)
    at com.sdl.delivery.content.model.core.datafetcher.ItemsConnectionDataFetcher.fetch(ItemsConnectionDataFetcher.java:39)
    at com.sdl.delivery.content.model.core.datafetcher.AbstractListDataFetcher.get(AbstractListDataFetcher.java:39)
    at graphql.annotations.connection.PaginatedDataConnectionFetcher.get(PaginatedDataConnectionFetcher.java:45)
    at graphql.annotations.connection.PaginatedDataConnectionFetcher.get(PaginatedDataConnectionFetcher.java:35)
    at graphql.annotations.dataFetchers.connection.ConnectionDataFetcher.get(ConnectionDataFetcher.java:49)
    at graphql.annotations.dataFetchers.connection.AsyncConnectionDataFetcher.lambda$get$0(AsyncConnectionDataFetcher.java:34)
    ... 6 common frames omitted
2020-04-20 06:46:40,041 ERROR ContentAPIGraphQLExecutor - Errors: [ExceptionWhileDataFetching{path=[items]exception=java.util.concurrent.CompletionException: java.lang.NullPointerExceptionlocations=[SourceLocation{line=2, column=2}]}]
  • Are the keys in your customMeta properties correct? – Neil Apr 21 at 14:24
  • Hi @Neil, yes those properties are present with publication metadatas in tridion docs – Neetesh Narvaria Apr 22 at 4:03
  • 1
    The customMeta/valueType = null looks suspicious. Should that not have a value? – Rick Pannekoek Apr 22 at 19:47
  • Hi @RickPannekoek, that's a good catch, thank you for that :), i tried graphql by removing customMeta/valueType it worked, also i tried by setting up customMeta/valueType="STRING" that also worked. so on dxa code i was missing "customMetaCriteria.setValueType(CustomMetaValueType.STRING);", which is now working, Thank you so much for this. – Neetesh Narvaria Apr 23 at 4:14
  • Good to hear that that was indeed the problem and you found the way to fix it. I created an Answer for it. – Rick Pannekoek Apr 23 at 15:33
1

The error is caused by the fact that customMeta/valueType = null

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.