mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
Start with graphql
This commit is contained in:
parent
d48eaa0d1f
commit
5c906d0dc2
@ -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',
|
||||
|
||||
@ -76,7 +76,7 @@ const sanitizeEntity = (dataSource, options) => {
|
||||
}
|
||||
|
||||
return sanitizeEntity(entity, {
|
||||
model: strapi.db.getModelByGlobalId(entity.__contentType),
|
||||
model: strapi.getModel(entity.__contentType),
|
||||
...baseOptions,
|
||||
});
|
||||
};
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user