In GraphQL
query, you can ask for specific fields(For example, first name and email of the
employees) information.
For
example,
{ employees { firstName email lastName permanentAddress{ city } } }
Above
query requests for all the employees firstName, email, lastName and city field
of permanentAddress type.
When you
ran above query, you will get beow kind of response.
{ "data": { "employees": [ { "firstName": "ram", "email": "krishna@abc.com", "lastName": "Gurram", "permanentAddress": { "city": "Bangalore" } }, { "firstName": "Joel", "email": "joel@abc.com", "lastName": "Chelli", "permanentAddress": { "city": "Chennai" } }, { "firstName": "Gopi", "email": "gopi@abc.com", "lastName": "Battu", "permanentAddress": { "city": "Bangalore" } } ] } }
As you see the response, you can confirm that GraphQL returns exactly the fields that are requested in query.
No comments:
Post a Comment