-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { setContext } from 'apollo-link-context' | ||
|
||
export default headers => | ||
setContext((_request, context) => { | ||
console.log('context', context) | ||
if (!context.graphqlContext) return {} | ||
if (!context.graphqlContext.headers) return {} | ||
return { | ||
headers: { | ||
...context.graphqlContext.headers, | ||
...headers | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { default as graphqlHttpRequest } from './http-request' | ||
export { default as graphqlLambdaRequest } from './lambda-request' | ||
export { default as createLambdaLink } from './lambda-link' | ||
export { default as createHeaderLink } from './header-link' | ||
export { default as hmacfetch } from './aws4-signer' | ||
export { default as formatError } from './format-error' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { ApolloLink } from 'apollo-link' | ||
import { graphqlRequest } from './core/graphql-request' | ||
import createHeaderLink from './header-link' | ||
import createLambdaLink from './lambda-link' | ||
|
||
export default ({ lambdaName, region, request, variables, headers = {} }) => { | ||
const link = createLambdaLink({ | ||
lambdaName, | ||
region, | ||
headers | ||
}) | ||
const link = ApolloLink.from([ | ||
createHeaderLink(), | ||
createLambdaLink({ | ||
lambdaName, | ||
region | ||
}) | ||
]) | ||
return graphqlRequest({ name: lambdaName, link, request, variables }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters