mirror of
https://github.com/strapi/strapi.git
synced 2025-10-14 17:43:01 +00:00
use default config instead of the dedicated service
This commit is contained in:
parent
f025deffe9
commit
a7592e04a9
10
packages/plugins/graphql/server/bootstrap.js
vendored
10
packages/plugins/graphql/server/bootstrap.js
vendored
@ -31,9 +31,9 @@ module.exports = async ({ strapi }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const { config } = strapi.plugin('graphql').service('utils');
|
||||
const { config } = strapi.plugin('graphql');
|
||||
|
||||
const path = config.endpoint;
|
||||
const path = config('endpoint');
|
||||
|
||||
const defaultServerConfig = {
|
||||
// Schema
|
||||
@ -46,7 +46,7 @@ module.exports = async ({ strapi }) => {
|
||||
}),
|
||||
|
||||
// Validation
|
||||
validationRules: [depthLimit(config.depthLimit)],
|
||||
validationRules: [depthLimit(config('depthLimit'))],
|
||||
|
||||
// Errors
|
||||
formatError: formatGraphqlError,
|
||||
@ -63,10 +63,10 @@ module.exports = async ({ strapi }) => {
|
||||
],
|
||||
};
|
||||
|
||||
const serverConfig = merge(defaultServerConfig, config.apolloServer);
|
||||
const serverConfig = merge(defaultServerConfig, config('apolloServer'));
|
||||
|
||||
// Handle subscriptions
|
||||
if (config.subscriptions) {
|
||||
if (config('subscriptions')) {
|
||||
const subscriptionServer = SubscriptionServer.create(
|
||||
{ schema, execute, subscribe },
|
||||
{ server: strapi.server.httpServer, path }
|
||||
|
13
packages/plugins/graphql/server/config/default-config.js
Normal file
13
packages/plugins/graphql/server/config/default-config.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
shadowCRUD: true,
|
||||
|
||||
endpoint: '/graphql',
|
||||
|
||||
subscriptions: false,
|
||||
|
||||
maxLimit: -1,
|
||||
|
||||
apolloServer: {},
|
||||
};
|
7
packages/plugins/graphql/server/config/index.js
Normal file
7
packages/plugins/graphql/server/config/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const defaultConfig = require('./default-config');
|
||||
|
||||
module.exports = {
|
||||
default: defaultConfig,
|
||||
};
|
@ -27,7 +27,7 @@ const {
|
||||
|
||||
module.exports = ({ strapi }) => {
|
||||
const { service: getGraphQLService } = strapi.plugin('graphql');
|
||||
const { config } = getGraphQLService('utils');
|
||||
const { config } = strapi.plugin('graphql');
|
||||
|
||||
const { KINDS, GENERIC_MORPH_TYPENAME } = getGraphQLService('constants');
|
||||
const extensionService = getGraphQLService('extension');
|
||||
@ -38,7 +38,7 @@ module.exports = ({ strapi }) => {
|
||||
let builders;
|
||||
|
||||
const buildSchema = () => {
|
||||
const isShadowCRUDEnabled = !!config.shadowCRUD;
|
||||
const isShadowCRUDEnabled = !!config('shadowCRUD');
|
||||
|
||||
// Create a new empty type registry
|
||||
registry = getGraphQLService('type-registry').new();
|
||||
|
@ -25,7 +25,7 @@ const introspectionQueries = [
|
||||
* @return {GraphQLSchema}
|
||||
*/
|
||||
const wrapResolvers = ({ schema, strapi, extension = {} }) => {
|
||||
const { config: graphQLConfig } = strapi.plugin('graphql').service('utils');
|
||||
const { config: graphQLConfig } = strapi.plugin('graphql');
|
||||
// Get all the registered resolvers configuration
|
||||
const { resolversConfig = {} } = extension;
|
||||
|
||||
@ -34,7 +34,7 @@ const wrapResolvers = ({ schema, strapi, extension = {} }) => {
|
||||
|
||||
const typeMap = schema.getTypeMap();
|
||||
|
||||
if (!graphQLConfig.subscriptions) {
|
||||
if (!graphQLConfig('subscriptions')) {
|
||||
delete typeMap.Subscription;
|
||||
}
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* GraphQL config helper with consistent defaults values
|
||||
*/
|
||||
module.exports = ({ strapi }) => {
|
||||
const { config: graphQLConfig } = strapi.plugin('graphql');
|
||||
|
||||
return {
|
||||
get shadowCRUD() {
|
||||
return graphQLConfig('shadowCRUD', true);
|
||||
},
|
||||
|
||||
get subscriptions() {
|
||||
return graphQLConfig('subscriptions', false);
|
||||
},
|
||||
|
||||
get endpoint() {
|
||||
return graphQLConfig('endpoint', '/graphql');
|
||||
},
|
||||
|
||||
get defaultLimit() {
|
||||
return graphQLConfig('defaultLimit');
|
||||
},
|
||||
|
||||
get maxLimit() {
|
||||
return graphQLConfig('maxLimit', -1);
|
||||
},
|
||||
|
||||
get depthLimit() {
|
||||
return graphQLConfig('depthLimit');
|
||||
},
|
||||
|
||||
get apolloServer() {
|
||||
return graphQLConfig('apolloServer', {});
|
||||
},
|
||||
};
|
||||
};
|
@ -3,11 +3,9 @@
|
||||
const mappers = require('./mappers');
|
||||
const attributes = require('./attributes');
|
||||
const naming = require('./naming');
|
||||
const config = require('./config');
|
||||
|
||||
module.exports = context => ({
|
||||
naming: naming(context),
|
||||
attributes: attributes(context),
|
||||
mappers: mappers(context),
|
||||
config: config(context),
|
||||
});
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
const bootstrap = require('./server/bootstrap');
|
||||
const services = require('./server/services');
|
||||
const config = require('./server/config');
|
||||
|
||||
module.exports = (/* strapi, config */) => {
|
||||
return {
|
||||
config,
|
||||
bootstrap,
|
||||
services,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user