mirror of
https://github.com/strapi/strapi.git
synced 2025-12-08 04:54:44 +00:00
Merge branch 'master' into tech/middleware-load
This commit is contained in:
commit
0d480fe11d
@ -216,6 +216,7 @@ type Query {
|
|||||||
test(id: ID!): MypluginTest
|
test(id: ID!): MypluginTest
|
||||||
tests(sort: String, limit: Int, start: Int, where: JSON): [MypluginTest]
|
tests(sort: String, limit: Int, start: Int, where: JSON): [MypluginTest]
|
||||||
me: UsersPermissionsMe
|
me: UsersPermissionsMe
|
||||||
|
userCustomRoute: String
|
||||||
}
|
}
|
||||||
|
|
||||||
input RoleInput {
|
input RoleInput {
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
module.exports = {
|
||||||
|
query: `
|
||||||
|
userCustomRoute: String
|
||||||
|
`,
|
||||||
|
resolver: {
|
||||||
|
Query: {
|
||||||
|
userCustomRoute: {
|
||||||
|
resolver: {
|
||||||
|
plugin: 'users-permissions',
|
||||||
|
handler: 'UsersPermissions.customRoute',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -23,8 +23,11 @@ module.exports = strapi => {
|
|||||||
strapi.config.hook.load.after.push('graphql');
|
strapi.config.hook.load.after.push('graphql');
|
||||||
// Load core utils.
|
// Load core utils.
|
||||||
|
|
||||||
const configs = await loadConfigs({ appPath, installedPlugins });
|
const { api, plugins, extensions } = await loadConfigs({
|
||||||
_.merge(strapi, configs);
|
appPath,
|
||||||
|
installedPlugins,
|
||||||
|
});
|
||||||
|
_.merge(strapi, { api, plugins });
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a merge of all the GraphQL configuration.
|
* Create a merge of all the GraphQL configuration.
|
||||||
@ -37,11 +40,15 @@ module.exports = strapi => {
|
|||||||
_.get(strapi.plugins[key], 'config.schema.graphql', {})
|
_.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
|
// save the final schema in the plugin's config
|
||||||
_.set(
|
_.set(
|
||||||
strapi,
|
strapi,
|
||||||
['plugins', 'graphql', 'config', '_schema', 'graphql'],
|
['plugins', 'graphql', 'config', '_schema', 'graphql'],
|
||||||
mergeSchemas([...apisSchemas, ...pluginsSchemas])
|
mergeSchemas([...apisSchemas, ...pluginsSchemas, ...extensionsSchemas])
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -16,21 +16,26 @@ const loadPluginsGraphqlConfig = async installedPlugins => {
|
|||||||
);
|
);
|
||||||
_.set(root, ['plugins', pluginName], result);
|
_.set(root, ['plugins', pluginName], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadLocalPluginsGraphqlConfig = async appPath =>
|
const loadLocalPluginsGraphqlConfig = async appPath =>
|
||||||
loadUtils.loadFiles(appPath, 'plugins/**/config/*.graphql?(.js)');
|
loadUtils.loadFiles(appPath, 'plugins/**/config/*.graphql?(.js)');
|
||||||
|
|
||||||
|
const loadExtensions = async appPath =>
|
||||||
|
loadUtils.loadFiles(appPath, 'extensions/**/config/*.graphql?(.js)');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the graphql config files
|
* Loads the graphql config files
|
||||||
*/
|
*/
|
||||||
module.exports = async ({ appPath, installedPlugins }) => {
|
module.exports = async ({ appPath, installedPlugins }) => {
|
||||||
const [apis, plugins, localPlugins] = await Promise.all([
|
const [apis, plugins, localPlugins, extensions] = await Promise.all([
|
||||||
loadApisGraphqlConfig(appPath),
|
loadApisGraphqlConfig(appPath),
|
||||||
loadPluginsGraphqlConfig(installedPlugins),
|
loadPluginsGraphqlConfig(installedPlugins),
|
||||||
loadLocalPluginsGraphqlConfig(appPath),
|
loadLocalPluginsGraphqlConfig(appPath),
|
||||||
|
loadExtensions(appPath),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return _.merge({}, apis, plugins, localPlugins);
|
return _.merge({}, apis, plugins, extensions, localPlugins);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user