1

This question is about getting the grapqhl request body in server; my use-case is:

I am having a class with the following fields and a corresponding table in PostgreSQL:

1)ID

2)Name

3)age

4)Department

5)City

6)Gender . . .

I am using graphql with apollo-server in nodejs.

My graphql sample request :

Query{
   Persons{
     id
     name
   }
}

Query{
   Person(id:123){
     id
     name
     age
     gender
   }
}

The problem is that for every graphql request I am fetching all columns from Postgresql table :

select * from Person;

select * from Person where id=123;

If I know what columns are there in the graphql request body, I will fetch those columns from table, which would be more efficient, Is there any way for achieving this ?

naveen
  • 560
  • 6
  • 15
  • You can parse the `info` parameter to determine which fields were requested. Please see the linked dupe for additional details. – Daniel Rearden Sep 03 '19 at 01:41

0 Answers0