Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info to custom resolvers and add formatError to GraphQL service #6524

Merged
merged 3 commits into from Jun 16, 2020

Conversation

iicdii
Copy link
Contributor

@iicdii iicdii commented Jun 3, 2020

Description of what you did:

1. Add info to custom resolvers

I added info argument to custom resolvers, which has useful informations such as operation name, request query body and so on.

  resolver: async (
    obj,
    options,
    ctx,
    info // it was missing
  ) => {
  
  }

2. Add formatError service

Apollo-server supports formatting error, but so far there has been no way to use this option. So I add formatError service and connect to ApolloServer options, so that users can customize it by adding service in extensions/graphql/services/format-error.js.

Usage example

// extensions/graphql/services/format-error.js
const Sentry = require('@sentry/node');

const formatError = err => {
  Sentry.captureException(err.originalError);
  return err;
};

module.exports = {
  formatError,
};

As you see in the example, it's useful when you use error tracking tools like Sentry. For now you can't capture GraphQL error anywhere, because GraphQL plugin hook runs after all middleware and hooks.

Signed-off-by: harimkims <harimkims@gmail.com>
@codecov
Copy link

codecov bot commented Jun 3, 2020

Codecov Report

Merging #6524 into master will increase coverage by 0.13%.
The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6524      +/-   ##
==========================================
+ Coverage   19.85%   19.98%   +0.13%     
==========================================
  Files         857      858       +1     
  Lines       12076    12097      +21     
  Branches     1963     1965       +2     
==========================================
+ Hits         2398     2418      +20     
- Misses       8093     8094       +1     
  Partials     1585     1585              
Flag Coverage Δ
#front 14.67% <50.00%> (+<0.01%) ⬆️
#unit 41.71% <95.00%> (+0.45%) ⬆️
Impacted Files Coverage Δ
...admin/src/containers/InstalledPluginsPage/index.js 7.14% <ø> (ø)
...kages/strapi-admin/admin/src/translations/index.js 100.00% <ø> (ø)
...-manager/admin/src/components/DynamicZone/index.js 0.00% <ø> (ø)
...in-content-manager/admin/src/translations/index.js 0.00% <ø> (ø)
...lder/admin/src/containers/FormModal/utils/forms.js 0.00% <0.00%> (ø)
...ntent-type-builder/admin/src/translations/index.js 0.00% <ø> (ø)
...ugin-documentation/admin/src/translations/index.js 0.00% <ø> (ø)
...trapi-plugin-email/admin/src/translations/index.js 0.00% <ø> (ø)
.../containers/InputModalStepper/InputModalStepper.js 0.00% <ø> (ø)
...-upload/admin/src/containers/ModalStepper/index.js 0.00% <ø> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 534a199...f7fba97. Read the comment docs.

@alexandrebodin alexandrebodin added source: plugin:graphql Source is plugin/graphql package issue: enhancement Issue suggesting an enhancement to an existing feature labels Jun 16, 2020
@alexandrebodin alexandrebodin added this to the 3.0.3 milestone Jun 16, 2020
Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexandrebodin alexandrebodin merged commit 465c19d into strapi:master Jun 16, 2020
@iicdii iicdii deleted the feautre/graphql-imporve branch June 16, 2020 13:01
iicdii added a commit to iicdii/strapi that referenced this pull request Jul 2, 2020
…trapi#6524)

* Add info to custom resolvers, add formatError to GraphQL service

Signed-off-by: harimkims <harimkims@gmail.com>

* remove format-error service and use config instead

Signed-off-by: harimkims <harimkims@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: plugin:graphql Source is plugin/graphql package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants