Start with graphql

This commit is contained in:
Alexandre Bodin 2021-07-19 12:39:43 +02:00
parent d48eaa0d1f
commit 5c906d0dc2
5 changed files with 5 additions and 7 deletions

View File

@ -253,6 +253,7 @@ describe('Role CRUD End to End', () => {
[{ name: 'new role 4', description: 'description' }],
[{ name: 'new role 5', description: 'description' }],
];
test.each(rolesToCreate)('can create %p', async role => {
let res = await rq({
url: '/admin/roles',

View File

@ -76,7 +76,7 @@ const sanitizeEntity = (dataSource, options) => {
}
return sanitizeEntity(entity, {
model: strapi.db.getModelByGlobalId(entity.__contentType),
model: strapi.getModel(entity.__contentType),
...baseOptions,
});
};

View File

@ -36,7 +36,6 @@ module.exports = strapi => {
return {
async beforeInitialize() {
return;
// Try to inject this hook just after the others hooks to skip the router processing.
if (!strapi.config.get('hook.load.after')) {
_.set(strapi.config.hook.load, 'after', []);
@ -74,8 +73,6 @@ module.exports = strapi => {
},
initialize() {
// FIXME: connect new GQL API
return;
const schema = strapi.plugins.graphql.services['schema-generator'].generateSchema();
if (_.isEmpty(schema)) {

View File

@ -116,12 +116,12 @@ module.exports = {
return `[${typeName}]${required ? '!' : ''}`;
}
const ref = attribute.model || attribute.collection;
const ref = attribute.target;
// Association
if (ref && ref !== '*') {
// Add bracket or not
const globalId = strapi.db.getModel(ref, attribute.plugin).globalId;
const globalId = strapi.getModel(ref).globalId;
const plural = !_.isEmpty(attribute.collection);
if (plural) {

View File

@ -135,7 +135,7 @@ const removeIdsMut = (model, entry) => {
}
});
} else if (attr.type === 'component') {
const [model] = strapi.db.getModelsByAttribute(attr);
const model = strapi.components[attr.component];
if (isArray(value)) {
value.forEach(compo => removeIdsMut(model, compo));
} else {