After creating a GraphQL API in a NestJS project with TypeORM, I've been trying my hardest to avoid adding REST API endpoints. Once I started implementing some basic auth via JWT's (w/access tokens & refresh tokens), I wondered why it's not common to use GraphQL mutations for this purpose...
I tried making everything the same, including the length of names for each endpoint/query. Here are my results:
**Note: all GraphQL requests (queries and mutations) are POST requests.
API | Type | Avg Response Time | Sample Response Times |
---|---|---|---|
REST | GET | 0.329s | 0.280s, 0.261s, 0.316s, 0.472s, 0.314s |
REST | POST | 0.561s | 0.690s, 0.454s, 0.479s, 0.814s, 0.369s |
GraphQL | Query | 0.795s | 0.735s, 0.717s, 0.716s, 1.133s, 0.674s |
GraphQL | Mutation | 0.711s | 0.713s, 0.753s, 0.684s, 0.703s, 0.700s |
Top comments (0)