Commit 4e4081d1 authored by Giannis Kopanas's avatar Giannis Kopanas Committed by Alexandros Georgantas

feat(dynamicomponenttype): add graphql schema query mutations table

parent 3378924b
type applicationParameter {
id: ID
context: String
area: String
config: String
}
type updateParametersInput {
context: String
area: String
config: String
}
extend type Query {
getApplicationParameters(context: String!, area: String!): [ApplicationParameter!]!
}
extend type Mutation {
updateApplicationParameters(input: updateParametersInput!): ApplicationParameter!
}
const { ApplicationParameter } = require('editoria-data-model/src').models
const getApplicationParameters = async (_, args, ctx) => {
const { context, area } = args
const parameters = await ApplicationParameter.query().where({ context, area })
return parameters
}
const updateApplicationParameter = async (_, args, ctx) => {
const { context, area, config } = args
const parameter = await ApplicationParameter.query().findOne({
context,
area,
})
const updatedParameter = await parameter.$query().updateAndFetch({ config })
return updatedParameter
}
module.exports = {
Query: {
getApplicationParameters,
},
Mutation: {
updateApplicationParameter,
},
}
module.exports = {
resolvers: require('./applicationParameter.resolvers'),
typeDefs: require('../graphqlLoaderUtil')(
'applicationParameter/applicationParameter.graphql',
),
}
// TO DO -- review foreign id and foreign type
const Base = require('../editoriaBase')
const { stringNotEmpty, object } = require('../helpers').schema
class ApplicationParameter extends Base {
constructor(properties) {
super(properties)
this.type = 'applicationParameter'
}
static get tableName() {
return 'application_parameters'
}
static get schema() {
return {
type: 'object',
required: ['stringNotEmpty'],
properties: {
context: stringNotEmpty,
area: stringNotEmpty,
config: object,
},
}
}
}
module.exports = ApplicationParameter
const model = require('./applicationParameter')
module.exports = {
model,
modelName: 'ApplicationParameter',
}
create table application_parameter (
-- base
id uuid primary key,
type text not null,
created timestamp with time zone not null default current_timestamp,
updated timestamp with time zone,
--own
context text not null
area text not null
config jsonb
);
CREATE INDEX ON application_parameter (context);
CREATE INDEX ON application_parameter (area);
const applicationParameter = require('./applicationParameter')
const book = require('./book')
const bookCollection = require('./bookCollection')
const bookCollectionTranslation = require('./bookCollectionTranslation')
......@@ -22,6 +23,7 @@ module.exports = {
customTag,
team,
user,
applicationParameter,
bookCollection,
bookCollectionTranslation,
bookComponent,
......@@ -35,6 +37,7 @@ module.exports = {
loader,
template,
models: {
ApplicationParameter: applicationParameter.model,
Book: book.model,
BookCollection: bookCollection.model,
BookCollectionTranslation: bookCollectionTranslation.model,
......
......@@ -13301,19 +13301,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"
prompt@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prompt/-/prompt-1.0.0.tgz#8e57123c396ab988897fb327fd3aedc3e735e4fe"
integrity sha1-jlcSPDlquYiJf7Mn/Trtw+c15P4=
dependencies:
colors "^1.1.2"
pkginfo "0.x.x"
read "1.0.x"
revalidator "0.1.x"
utile "0.3.x"
winston "2.1.x"
prompt@flatiron/prompt#1c95d1d8d333b5fbc13fa5f0619f3dcf0d514f87:
prompt@^1.0.0, prompt@flatiron/prompt#1c95d1d8d333b5fbc13fa5f0619f3dcf0d514f87:
version "1.0.0"
resolved "https://codeload.github.com/flatiron/prompt/tar.gz/1c95d1d8d333b5fbc13fa5f0619f3dcf0d514f87"
dependencies:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment