formats graphql names to allow dashes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const Code = {
|
||||
slug: 'Code',
|
||||
slug: 'code',
|
||||
labels: {
|
||||
singular: 'Code',
|
||||
plural: 'Codes',
|
||||
|
||||
@@ -3,7 +3,7 @@ const Quote = require('../content-blocks/Quote');
|
||||
const NumberBlock = require('../content-blocks/Number');
|
||||
|
||||
module.exports = {
|
||||
slug: 'Flexible Content',
|
||||
slug: 'flexible-content',
|
||||
labels: {
|
||||
singular: 'Flexible Content',
|
||||
plural: 'Flexible Content',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const RichText = {
|
||||
slug: 'Rich Text',
|
||||
slug: 'rich-text',
|
||||
labels: {
|
||||
singular: 'Rich Text',
|
||||
plural: 'Rich Texts',
|
||||
|
||||
@@ -24,10 +24,13 @@ function buildMutationInputType(name, fields, parentName) {
|
||||
code: field => ({ type: withNullableType(field, GraphQLString) }),
|
||||
date: field => ({ type: withNullableType(field, GraphQLString) }),
|
||||
upload: field => ({ type: withNullableType(field, GraphQLString) }),
|
||||
'rich-text': field => ({ type: withNullableType(field, GraphQLString) }),
|
||||
html: field => ({ type: withNullableType(field, GraphQLString) }),
|
||||
checkbox: () => ({ type: GraphQLBoolean }),
|
||||
select: (field) => {
|
||||
const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`;
|
||||
let type = new GraphQLEnumType({
|
||||
name: `${combineParentName(parentName, field.name)}_MutationInput`,
|
||||
name: formattedName,
|
||||
values: field.options.reduce((values, option) => {
|
||||
if (typeof option === 'object' && option.value) {
|
||||
return {
|
||||
@@ -70,7 +73,7 @@ function buildMutationInputType(name, fields, parentName) {
|
||||
name: `${fullName}RelationTo`,
|
||||
values: field.relationTo.reduce((values, option) => ({
|
||||
...values,
|
||||
[option]: {
|
||||
[formatName(option)]: {
|
||||
value: option,
|
||||
},
|
||||
}), {}),
|
||||
@@ -107,7 +110,7 @@ function buildMutationInputType(name, fields, parentName) {
|
||||
|
||||
return {
|
||||
...schema,
|
||||
[field.name]: fieldSchema,
|
||||
[formatName(field.name)]: fieldSchema,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ function buildObjectType(name, fields, parentName, baseFields = {}) {
|
||||
if (fieldSchema) {
|
||||
return {
|
||||
...schema,
|
||||
[field.name]: fieldSchema(field),
|
||||
[formatName(field.name)]: fieldSchema(field),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,6 @@ function buildPoliciesType() {
|
||||
};
|
||||
});
|
||||
|
||||
fields[this.config.User.slug] = {
|
||||
type: new GraphQLObjectType({
|
||||
name: formatName(`${this.config.User.labels.singular}Policy`),
|
||||
fields: buildFields(this.config.User.labels.singular, ['create', 'read', 'update', 'delete']),
|
||||
}),
|
||||
};
|
||||
|
||||
Object.values(this.config.globals).forEach((global) => {
|
||||
fields[global.slug] = {
|
||||
type: new GraphQLObjectType({
|
||||
|
||||
@@ -195,7 +195,7 @@ const buildWhereInputType = (name, fields, parentName) => {
|
||||
...(fieldSchema.reduce((subFields, subField) => {
|
||||
return {
|
||||
...subFields,
|
||||
[subField.key]: subField.type,
|
||||
[formatName(subField.key)]: subField.type,
|
||||
};
|
||||
}, {})),
|
||||
};
|
||||
@@ -203,7 +203,7 @@ const buildWhereInputType = (name, fields, parentName) => {
|
||||
|
||||
return {
|
||||
...schema,
|
||||
[field.name]: fieldSchema,
|
||||
[formatName(field.name)]: fieldSchema,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user