1

Hi I am trying custom graphql call using dxa apis

i am calling this line

InputItemFilter inputItemFilter = new InputItemFilter();
inputItemFilter.setCustomMeta(customMetaCriteria);
InputSortParam inputSortParam = new InputSortParam();
inputSortParam.setSortBy(SortFieldType.LAST_PUBLISH_DATE);

ItemConnection itemConnection = getPcaClient().executeItemQuery(inputItemFilter,
                inputSortParam, new Pagination(), "",
                ContentIncludeMode.INCLUDE_DATA, false, null);

but i am getting error

"errorType": "ValidationError",             
"extensions": null,             
"message": "Variable 'inputSortParam' has coerced Null value for NonNull type 'SortOrderType!'",            
"path": null,           
"suppressed": [],           
"localizedMessage": "Variable 'inputSortParam' has coerced Null value for NonNull type 'SortOrderType!'"

or is there any method where i can only pass filter and get the respected output.

Could someone please advise what i am missing here.

3
  • added InputSortParam inputSortParam = new InputSortParam(); inputSortParam.setOrder(SortOrderType.Ascending); inputSortParam.setSortBy(SortFieldType.ITEM_ID); this fixed the problem Commented Apr 17, 2020 at 12:46
  • 1
    Good to see you found the problem. Please consider answering your own question with the solution with some explanation of what was wrong. This can help others (and even yourself in the future) who have a similar issue in the future. You can choose to post as a community answer or accept your own answer, though it's good to give others a chance to answer as well, in case someone has a correct answer with additional context that you prefer over your own. :-) Commented Apr 19, 2020 at 8:11
  • sure @AlvinReyes, i'll add this as answer thanks :) Commented Apr 20, 2020 at 6:14

1 Answer 1

3

added

InputSortParam inputSortParam = new InputSortParam();
inputSortParam.setOrder(SortOrderType.Ascending);
inputSortParam.setSortBy(SortFieldType.LAST_PUBLISH_DATE);

this fixed the problem. based on error i figured out both fields order and sortBy on are required InputSortParam.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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