7

I am getting following error while invoking GraphQL Query in java application -

"description": "Sub selection required for type Account of field accountQuery", "validationErrorType": "SubSelectionRequired", "queryPath": [ "accountQuery" ],

Here is my schema -

schema { query: Query }

type Query { accountQuery(nbr: String): Account }

type Account {
nbr: String
name: String ...
}

I have Account POJO defined and i am calling a Service in the backend based on the nbr value passed which is working fine.
Here is the rest request i am sending -

{ accountQuery(nbr: "123") }

Is the error due to missing id field and if so how do i mark "nbr" field as id ?

1 Answer 1

8

In GraphQL, you always need to provide the fields you'd like to get in return from the query.

For example, if you'd like to get from the Account object the name and nbr fields, you need to specify it like that:

{ accountQuery(nbr: "123") {name, nbr}}

This is a key concept in GraphQL, whenever you query, you need to provide a selection set, that is- A set of fields requested in the query, you can never just return a full object, need to specify exactly which fields you'd like

Sign up to request clarification or add additional context in comments.

1 Comment

This was the problem, Thanks.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.