Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pubsweet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
73
Issues
73
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pubsweet
pubsweet
Commits
3d499241
Commit
3d499241
authored
Aug 02, 2019
by
Jure
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(server): add default loaders correctly
parent
3be6bc28
Pipeline
#13090
failed with stages
in 8 minutes and 52 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
128 deletions
+127
-128
packages/server/src/graphql/loaders.js
packages/server/src/graphql/loaders.js
+11
-6
yarn.lock
yarn.lock
+116
-122
No files found.
packages/server/src/graphql/loaders.js
View file @
3d499241
...
...
@@ -22,15 +22,20 @@ module.exports = () => {
const
loaders
=
{}
components
.
forEach
(
component
=>
{
if
(
component
.
model
&&
component
.
modelName
&&
component
.
modelLoaders
)
{
if
(
component
.
model
&&
component
.
modelName
)
{
// Sets up the default loader, that gets model instances by id
// You can use it with e.g. context.loaders.User.load(id)
loaders
[
component
.
modelName
]
=
defaultLoader
(
component
.
model
)
Object
.
keys
(
component
.
modelLoaders
).
forEach
(
loaderName
=>
{
loaders
[
component
.
modelName
][
loaderName
]
=
new
DataLoader
(
component
.
modelLoaders
[
loaderName
],
)
})
// Allows for custom model loaders, that can be used e.g.
// context.loaders.User.customLoader.load(id)
if
(
component
.
modelLoaders
)
{
Object
.
keys
(
component
.
modelLoaders
).
forEach
(
loaderName
=>
{
loaders
[
component
.
modelName
][
loaderName
]
=
new
DataLoader
(
component
.
modelLoaders
[
loaderName
],
)
})
}
}
else
if
(
component
.
models
)
{
// If there are multiple models specified in a single component
// each can specify its own loaders
...
...
yarn.lock
View file @
3d499241
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment