Skip to content
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

Support querying + modifying Icarus theme config #368

Merged
merged 5 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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