-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from solocommand/icarus-config
Support querying + modifying Icarus theme config
- Loading branch information
Showing
8 changed files
with
77 additions
and
0 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
8 changes: 8 additions & 0 deletions
8
services/graphql-server/src/graphql/definitions/configuration/index.js
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,8 @@ | ||
const gql = require('graphql-tag'); | ||
const theme = require('./theme'); | ||
|
||
module.exports = gql` | ||
${theme} | ||
`; |
42 changes: 42 additions & 0 deletions
42
services/graphql-server/src/graphql/definitions/configuration/theme.js
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,42 @@ | ||
const gql = require('graphql-tag'); | ||
|
||
module.exports = gql` | ||
extend type Query { | ||
icarusConfiguration(input: IcarusConfigurationQueryInput!): IcarusConfiguration @findOne( | ||
model: "configuration.Theme" | ||
using: { id: "_id" } | ||
criteria: "configurationThemeIcarus" | ||
) | ||
@requiresAuth | ||
} | ||
extend type Mutation { | ||
updateIcarusConfiguration(input: UpdateIcarusConfigurationMutationInput!): IcarusConfiguration @requiresAuth | ||
} | ||
type IcarusConfiguration @applyInterfaceFields { | ||
id: ObjectID! @projection(localField: "_id") @value(localField: "_id") | ||
status: Int! @projection | ||
defaultHeader: JSON @projection | ||
defaultFooter: JSON @projection | ||
homePage: JSON @projection | ||
defaultPage: JSON @projection | ||
pages: [JSON]! @projection @arrayValue | ||
socialShare: [EntityStubSocial]! @projection @arrayValue | ||
templates: JSON @projection | ||
nativeAdTargetMap: JSON @projection | ||
loadMore: JSON @projection | ||
parameters: JSON @projection | ||
} | ||
input IcarusConfigurationQueryInput { | ||
id: ObjectID! | ||
} | ||
input UpdateIcarusConfigurationMutationInput { | ||
id: ObjectID! | ||
payload: JSON! | ||
} | ||
`; |
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
7 changes: 7 additions & 0 deletions
7
services/graphql-server/src/graphql/resolvers/configuration/index.js
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,7 @@ | ||
const deepAssign = require('deep-assign'); | ||
|
||
const theme = require('./theme'); | ||
|
||
module.exports = deepAssign( | ||
theme, | ||
); |
14 changes: 14 additions & 0 deletions
14
services/graphql-server/src/graphql/resolvers/configuration/theme.js
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,14 @@ | ||
module.exports = { | ||
/** | ||
* | ||
*/ | ||
Mutation: { | ||
updateIcarusConfiguration: async (_, { input }, { basedb }) => { | ||
const { id } = input; | ||
await basedb.strictFindOne('configuration.Theme', { _id: id, type: 'Icarus' }); | ||
const { _id, type, ...payload } = input.payload; | ||
await basedb.updateOne('configuration.Theme', { _id: id }, { $set: { ...payload } }); | ||
return basedb.strictFindOne('configuration.Theme', { _id: id, type: 'Icarus' }); | ||
}, | ||
}, | ||
}; |
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