-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: Add request context middleware for config and dependency injection in hooks #8480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mtrezza
merged 25 commits into
parse-community:alpha
from
Moumouls:moumouls/requestContextMiddleWare
Oct 14, 2025
+219
−29
Merged
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
56d6516
feat: add Parse Server config to standard request object
Moumouls d85f37f
wip
Moumouls 5926924
Merge remote-tracking branch 'origin/moumouls/addConfigUnderRequest' …
Moumouls 65f83c1
feat: requestContextMiddleware and config in hooks
Moumouls 8340f5b
fix: restore lock
Moumouls 8c8e1eb
fix: defs
Moumouls 748f68f
fix: import
Moumouls c98199c
Merge branch 'upstream/alpha' into moumouls/requestContextMiddleWare
Moumouls fbe389b
fix: lint
Moumouls 344116a
test: fix
Moumouls 9bbc7df
fix: ai suggestion
Moumouls 98b1287
test: use pure fetch
Moumouls 099d109
test: try to fix
Moumouls d08b157
test: try to fix
Moumouls 29a0d90
test: try again
Moumouls 264b1fa
fix: describe name
Moumouls 1841072
fix: use scoped path
Moumouls 03bc937
test: use single test
Moumouls 5804a19
test: split
Moumouls 3b99da0
Merge branch 'alpha' into moumouls/requestContextMiddleWare
Moumouls 481a5e4
test: avoid race
Moumouls 41aa216
Merge branch 'moumouls/requestContextMiddleWare' of github.com:Moumou…
Moumouls 4d42d53
Merge branch 'alpha' into moumouls/requestContextMiddleWare
mtrezza cedb2d2
Update spec/ParseGraphQLServer.spec.js
mtrezza 29feaf0
Merge branch 'alpha' into moumouls/requestContextMiddleWare
Moumouls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,40 @@ | ||
| describe('requestContextMiddlewareGraphQL', () => { | ||
|
|
||
| it('should support dependency injection on graphql api', async () => { | ||
| const requestContextMiddleware = (req, res, next) => { | ||
| req.config.aCustomController = 'aCustomController'; | ||
| next(); | ||
| }; | ||
| let called = false; | ||
| Parse.Cloud.beforeSave('_User', request => { | ||
| expect(request.config.aCustomController).toEqual('aCustomController'); | ||
| called = true; | ||
| }); | ||
| await reconfigureServer({ | ||
| requestContextMiddleware, | ||
| mountGraphQL: true, | ||
| graphQLPath: '/graphql', | ||
| }); | ||
|
|
||
| await fetch('http://localhost:8378/graphql', { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-Parse-Application-Id': 'test', | ||
| 'X-Parse-Master-Key': 'test', | ||
| }, | ||
| body: JSON.stringify({ | ||
| query: ` | ||
| mutation { | ||
| createUser(input: { fields: { username: "test", password: "test" } }) { | ||
| user { | ||
| objectId | ||
| } | ||
| } | ||
| } | ||
| `, | ||
| }), | ||
| }); | ||
| expect(called).toBeTruthy(); | ||
| }); | ||
| }); | ||
This file contains hidden or 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,21 @@ | ||
| describe('requestContextMiddlewareRest', () => { | ||
|
|
||
| it('should support dependency injection on rest api', async () => { | ||
| const requestContextMiddleware = (req, res, next) => { | ||
| req.config.aCustomController = 'aCustomController'; | ||
| next(); | ||
| }; | ||
|
|
||
| let called; | ||
Moumouls marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Parse.Cloud.beforeSave('_User', request => { | ||
| expect(request.config.aCustomController).toEqual('aCustomController'); | ||
| called = true; | ||
| }); | ||
| await reconfigureServer({ requestContextMiddleware }); | ||
| const user = new Parse.User(); | ||
| user.setUsername('test'); | ||
| user.setPassword('test'); | ||
| await user.signUp(); | ||
| expect(called).toBeTruthy(); | ||
| }); | ||
| }); | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.