Skip to content

Commit

Permalink
Merge pull request #368 from solocommand/icarus-config
Browse files Browse the repository at this point in the history
Support querying + modifying Icarus theme config
  • Loading branch information
zarathustra323 committed Mar 5, 2020
2 parents 568e34a + 4fb3f7f commit 7495d75
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/db/src/basedb.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { hrtime } = process;
* @type {string[]}
*/
const namespaces = [
'configuration',
'email',
'magazine',
'platform',
Expand Down
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}
`;
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!
}
`;
2 changes: 2 additions & 0 deletions services/graphql-server/src/graphql/definitions/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const gql = require('graphql-tag');

const auth = require('./auth');
const configuration = require('./configuration');
const email = require('./email');
const magazine = require('./magazine');
const platform = require('./platform');
Expand Down Expand Up @@ -114,6 +115,7 @@ input FormatDate {
timezone: String
}
${configuration}
${email}
${magazine}
${platform}
Expand Down
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,
);
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' });
},
},
};
2 changes: 2 additions & 0 deletions services/graphql-server/src/graphql/resolvers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const deepAssign = require('deep-assign');
const GraphQLJSON = require('graphql-type-json');
const { DateType, ObjectIDType } = require('../types');

const configuration = require('./configuration');
const platform = require('./platform');
const website = require('./website');
const magazine = require('./magazine');
Expand All @@ -11,6 +12,7 @@ const auth = require('./auth');

module.exports = deepAssign(
auth,
configuration,
googleDataApi,
platform,
website,
Expand Down
1 change: 1 addition & 0 deletions services/graphql-server/src/graphql/utils/criteria-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const taxonomyTypes = getDefaultTaxonomyTypes();

const criterion = {
assetImage: () => ({ type: 'Image' }),
configurationThemeIcarus: () => ({ type: 'Icarus' }),
content: () => ({ type: { $in: contentTypes } }),
taxonomy: () => ({ type: { $in: taxonomyTypes } }),
emailNewsletter: () => ({ type: 'Newsletter' }),
Expand Down

0 comments on commit 7495d75

Please sign in to comment.