ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
137 stars 58 forks source link

Provide Access to the HTTP Response Object in the GraphQL Context #6799

Open ThisaruGuruge opened 2 months ago

ThisaruGuruge commented 2 months ago

Description:

Currently, in the Ballerina GraphQL service, users cannot access the HTTP response. This was done intentionally to decouple the HTTP and GraphQL protocols.

But this was before we introduced the graphql:Context object, which is, as the name suggests, contextual. Therefore, we can include the http:Response object in the graphql:Context so the users can access the response object inside the GraphQL service.

This can be helpful in many scenarios, including handling cookies, sending specific status codes with the GraphQL response, etc.

The http:Response object should be created inside the graphql:Context object and should be accessed via an API (either context.get() or a separate one like context.getResponse()).