-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: graphql headers handling, extract http create server from awili…
…x, middleware mocking enabled
- Loading branch information
1 parent
90576ac
commit faae4dd
Showing
5 changed files
with
27 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## GraphQL | ||
|
||
#### GraphQL headers | ||
In order to use headers in GraphQl query, once you created GraphQL handler, you can use context param: | ||
|
||
for example | ||
``` | ||
export const meQuery = async (parent: any, args: any, context: QueryContext) => { | ||
const token = ((context as any).req as Request).get("authorization")?.split(" ").at(1); // express Request | ||
const { result } = await context.queryBus.execute(new MeQuery({ token })); | ||
return result; | ||
}; | ||
``` | ||
|
||
REMEMBER: req param must be added in ApolloServer context setup |
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
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