-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: domain isolation not being enforced by gql
- Loading branch information
Showing
10 changed files
with
77 additions
and
50 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
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,13 +1,18 @@ | ||
import type { ExecutionContext } from '@nestjs/common'; | ||
import type { GqlContextType } from '@nestjs/graphql'; | ||
import { GqlExecutionContext } from '@nestjs/graphql'; | ||
import type { FastifyRequest } from 'fastify'; | ||
import type { ExecutionContext } from "@nestjs/common"; | ||
import type { GqlContextType } from "@nestjs/graphql"; | ||
import { GqlExecutionContext } from "@nestjs/graphql"; | ||
import type { FastifyRequest } from "fastify"; | ||
|
||
export const getRequest = (context: ExecutionContext): FastifyRequest => { | ||
if (context.getType<GqlContextType>() === 'graphql') { | ||
if (context.getType<GqlContextType>() === "graphql") { | ||
const ctx = GqlExecutionContext.create(context); | ||
return ctx.getContext().req; | ||
} | ||
|
||
return context.switchToHttp().getRequest<FastifyRequest>(); | ||
}; | ||
|
||
export const getRequestFromGraphQLContext = (context: any) => { | ||
if ("req" in context) return context.req as FastifyRequest; | ||
throw new Error("Could not get request from context"); | ||
}; |
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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ declare global { | |
state?: SSRData; | ||
pageHtml?: string; | ||
cookies?: string; | ||
forwardedHost?: string; | ||
} | ||
} | ||
} | ||
|
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