-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: Improve extensibility #9069
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2dc1b1c
feat: improve configurability of json-api builder and request-manager
runspired 387b989
fix types
runspired edb4d0c
add tests
runspired 8476396
fix prettier
runspired b2fc65b
fix forgottend debugger
runspired b288039
fixup lint
runspired ca9e31c
fix lint
runspired 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
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
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
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,48 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import Store from 'ember-data/store'; | ||
import RequestManager from '@ember-data/request'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
module('Integration | Store Extension', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test('We can create a store ', function (assert) { | ||
const { owner } = this; | ||
class CustomStore extends Store {} | ||
owner.register('service:store', CustomStore); | ||
const store = owner.lookup('service:store'); | ||
|
||
assert.true( | ||
store.requestManager instanceof RequestManager, | ||
'We create a request manager for the store automatically' | ||
); | ||
}); | ||
|
||
test('We can create a store with a custom request manager injected as a service', function (assert) { | ||
const { owner } = this; | ||
class CustomStore extends Store { | ||
@service requestManager!: RequestManager; | ||
} | ||
|
||
owner.register('service:store', CustomStore); | ||
owner.register('service:request-manager', RequestManager); | ||
const requestManager = owner.lookup('service:request-manager'); | ||
const store = owner.lookup('service:store'); | ||
|
||
assert.true(store.requestManager === requestManager, 'We can inject a custom request manager into the store'); | ||
}); | ||
|
||
test('We can create a store with a custom request manager initialized as a field', function (assert) { | ||
const { owner } = this; | ||
const requestManager = new RequestManager(); | ||
class CustomStore extends Store { | ||
requestManager = requestManager; | ||
} | ||
|
||
owner.register('service:store', CustomStore); | ||
const store = owner.lookup('service:store'); | ||
|
||
assert.true(store.requestManager === requestManager, 'We can inject a custom request manager into the store'); | ||
}); | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@runspired I have a question, do you think it would be useful to allow users to overwrite function that does
resourcePath
conversion right here as part of BuildURLConfig?Something like
or is it too crazy and I should go to sleep ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go to sleep :P
This is mostly already configurable in this way though maybe we could make it even more configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I know you can configure it using builder options, but would be nice to have it in single place like it used to be in adapter. It would cover 90% cases, and you can still change it on builder level