flattens user into collections

This commit is contained in:
James
2020-05-18 16:39:40 -04:00
parent 8809bcb573
commit 098b5be274
64 changed files with 321 additions and 431 deletions

View File

@@ -7,9 +7,8 @@ const buildBlockType = require('./schema/buildBlockType');
const buildPoliciesType = require('./schema/buildPoliciesType');
const buildLocaleInputType = require('./schema/buildLocaleInputType');
const buildFallbackLocaleInputType = require('./schema/buildFallbackLocaleInputType');
const registerCollections = require('../collections/graphql/register');
const registerGlobals = require('../globals/graphql/register');
const initUser = require('../users/graphql/init');
const initCollections = require('../collections/graphql/init');
const initGlobals = require('../globals/graphql/init');
const buildWhereInputType = require('./schema/buildWhereInputType');
class GraphQL {
@@ -32,15 +31,13 @@ class GraphQL {
this.buildWhereInputType = buildWhereInputType;
this.buildObjectType = buildObjectType.bind(this);
this.buildPoliciesType = buildPoliciesType.bind(this);
this.registerCollections = registerCollections.bind(this);
this.initUser = initUser.bind(this);
this.registerGlobals = registerGlobals.bind(this);
this.initCollections = initCollections.bind(this);
this.initGlobals = initGlobals.bind(this);
}
init() {
this.registerCollections();
this.initUser();
this.registerGlobals();
this.initCollections();
this.initGlobals();
const query = new GraphQLObjectType(this.Query);
const mutation = new GraphQLObjectType(this.Mutation);

View File

@@ -83,8 +83,6 @@ function buildObjectType(name, fields, parentName, baseFields = {}) {
return this.types.blockTypes[data.blockType];
},
});
} else if (relationTo === this.config.User.slug) {
({ type } = this.User.graphQL);
} else {
({ type } = this.collections[relationTo].graphQL);
}
@@ -203,13 +201,7 @@ function buildObjectType(name, fields, parentName, baseFields = {}) {
),
};
} else {
let whereFields;
if (relationTo === this.config.User.slug) {
whereFields = this.User.config.fields;
} else {
whereFields = this.collections[relationTo].config.fields;
}
const whereFields = this.collections[relationTo].config.fields;
relationship.args.where = {
type: this.buildWhereInputType(