Skip to content

Commit

Permalink
Merge branch 'master' into mlrus
Browse files Browse the repository at this point in the history
  • Loading branch information
alxnkt committed Jun 16, 2020
2 parents 10cbb42 + 6774667 commit 3ac1ad0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/v3.x/concepts/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ The session doesn't work with `mongo` as a client. The package that we should us

- [`csp`](https://en.wikipedia.org/wiki/Content_Security_Policy)
- `enabled` (boolean): Enable or disable CSP to avoid Cross Site Scripting (XSS) and data injection attacks.
- `policy` (string): Configures the `Content-Security-Policy` header. If not specified uses default value. Default value: `undefined`.
- [`p3p`](https://en.wikipedia.org/wiki/P3P)
- `enabled` (boolean): Enable or disable p3p.
- [`hsts`](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security)
Expand Down
5 changes: 5 additions & 0 deletions packages/strapi-plugin-graphql/hooks/graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ module.exports = strapi => {
context: ctx,
};
},
formatError: err => {
const formatError = _.get(strapi.plugins.graphql, 'config.formatError', null);

return typeof formatError === 'function' ? formatError(err) : err;
},
validationRules: [depthLimit(strapi.plugins.graphql.config.depthLimit)],
tracing: _.get(strapi.plugins.graphql, 'config.tracing', false),
playground: false,
Expand Down
8 changes: 4 additions & 4 deletions packages/strapi-plugin-graphql/services/resolvers-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const buildMutation = (mutationName, config) => {

// custom resolvers
if (_.isFunction(resolver)) {
return async (root, options = {}, graphqlContext) => {
return async (root, options = {}, graphqlContext, info) => {
const ctx = buildMutationContext({ options, graphqlContext });

await policiesMiddleware(ctx);
graphqlContext.context = ctx;

return resolver(root, options, graphqlContext);
return resolver(root, options, graphqlContext, info);
};
}

Expand Down Expand Up @@ -91,13 +91,13 @@ const buildQuery = (queryName, config) => {

// custom resolvers
if (_.isFunction(resolver)) {
return async (root, options = {}, graphqlContext) => {
return async (root, options = {}, graphqlContext, info) => {
const { ctx, opts } = buildQueryContext({ options, graphqlContext });

await policiesMiddleware(ctx);
graphqlContext.context = ctx;

return resolver(root, opts, graphqlContext);
return resolver(root, opts, graphqlContext, info);
};
}

Expand Down

0 comments on commit 3ac1ad0

Please sign in to comment.