segpacto / gql-gateway

gql-gateway
MIT License
15 stars 4 forks source link

adds plugins to Apollo Server to append custom headers and x-forwarded header to gql response and backend requests #18

Closed nischalsource closed 3 years ago

nischalsource commented 3 years ago

Summary

1. I've introduced a hook onto the Apollo Provider instantiation in './index.js' This hook allows for the injecting of Apollo Server Plugins. https://www.apollographql.com/docs/apollo-server/v2/integrations/plugins/

2. Apollo Server Response to Apollo-Client Request I've also written a plugin This plugin attaches x-forward headers from incoming gql Request (from website) to returning Response (back to website)

3. Apollo-Server Request to backend API In the file 'helpers/callbackend.js' I've reattached x-forward header from incoming gql Request (from website) to outgoing Requests (to backend api)