Merge branch 'master' into tech/middleware-load

This commit is contained in:
Alexandre BODIN 2019-06-12 18:34:35 +02:00 committed by GitHub
commit 0d480fe11d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 5 deletions

View File

@ -216,6 +216,7 @@ type Query {
test(id: ID!): MypluginTest
tests(sort: String, limit: Int, start: Int, where: JSON): [MypluginTest]
me: UsersPermissionsMe
userCustomRoute: String
}
input RoleInput {

View File

@ -0,0 +1,15 @@
module.exports = {
query: `
userCustomRoute: String
`,
resolver: {
Query: {
userCustomRoute: {
resolver: {
plugin: 'users-permissions',
handler: 'UsersPermissions.customRoute',
},
},
},
},
};

View File

@ -23,8 +23,11 @@ module.exports = strapi => {
strapi.config.hook.load.after.push('graphql');
// Load core utils.
const configs = await loadConfigs({ appPath, installedPlugins });
_.merge(strapi, configs);
const { api, plugins, extensions } = await loadConfigs({
appPath,
installedPlugins,
});
_.merge(strapi, { api, plugins });
/*
* Create a merge of all the GraphQL configuration.
@ -37,11 +40,15 @@ module.exports = strapi => {
_.get(strapi.plugins[key], 'config.schema.graphql', {})
);
const extensionsSchemas = Object.keys(extensions || {}).map(key =>
_.get(extensions[key], 'config.schema.graphql', {})
);
// save the final schema in the plugin's config
_.set(
strapi,
['plugins', 'graphql', 'config', '_schema', 'graphql'],
mergeSchemas([...apisSchemas, ...pluginsSchemas])
mergeSchemas([...apisSchemas, ...pluginsSchemas, ...extensionsSchemas])
);
},

View File

@ -16,21 +16,26 @@ const loadPluginsGraphqlConfig = async installedPlugins => {
);
_.set(root, ['plugins', pluginName], result);
}
return root;
};
const loadLocalPluginsGraphqlConfig = async appPath =>
loadUtils.loadFiles(appPath, 'plugins/**/config/*.graphql?(.js)');
const loadExtensions = async appPath =>
loadUtils.loadFiles(appPath, 'extensions/**/config/*.graphql?(.js)');
/**
* Loads the graphql config files
*/
module.exports = async ({ appPath, installedPlugins }) => {
const [apis, plugins, localPlugins] = await Promise.all([
const [apis, plugins, localPlugins, extensions] = await Promise.all([
loadApisGraphqlConfig(appPath),
loadPluginsGraphqlConfig(installedPlugins),
loadLocalPluginsGraphqlConfig(appPath),
loadExtensions(appPath),
]);
return _.merge({}, apis, plugins, localPlugins);
return _.merge({}, apis, plugins, extensions, localPlugins);
};