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

feat: GraphQL support #31

Merged
merged 9 commits into from
Mar 10, 2020
Merged

feat: GraphQL support #31

merged 9 commits into from
Mar 10, 2020

Conversation

9renpoto
Copy link
Collaborator

@9renpoto 9renpoto commented Feb 3, 2020

Closes #20
Closes #17

  • GraphQL Support
  • test/test-project move to example

@coveralls
Copy link

coveralls commented Feb 3, 2020

Pull Request Test Coverage Report for Build 105

  • 21 of 23 (91.3%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+5.9%) to 91.463%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/raven.interceptor.ts 19 21 90.48%
Files with Coverage Reduction New Missed Lines %
lib/raven.interceptor.ts 1 91.03%
Totals Coverage Status
Change from base Build 102: 5.9%
Covered Lines: 47
Relevant Lines: 50

💛 - Coveralls

@9renpoto 9renpoto changed the title feat: GraphQL support WIP feat: GraphQL support Feb 4, 2020
Object {
"data": null,
"errors": Array [
[GraphQLError: Cannot read property 'headers' of undefined],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

parse Context error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed: #29

Object {
"data": null,
"errors": Array [
[GraphQLError: [object Object]],
Copy link
Collaborator Author

@9renpoto 9renpoto Feb 4, 2020

Choose a reason for hiding this comment

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

@nestjs/graphql support apollo-server-errors
if capture @nestjs/common Exceptions (ex. throw service class), needs custom exception filters

Copy link
Owner

Choose a reason for hiding this comment

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

I don't understand exactly what you mean.

@9renpoto 9renpoto mentioned this pull request Feb 4, 2020
@9renpoto 9renpoto changed the title WIP feat: GraphQL support feat: GraphQL support Feb 4, 2020
@9renpoto 9renpoto marked this pull request as ready for review February 4, 2020 03:25
@9renpoto
Copy link
Collaborator Author

9renpoto commented Feb 4, 2020

@mentos1386 Hello, please review it. thank you : )

exception,
);
default:
return this.captureGraphQLException(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

graphql is not include default ContextType (refs).

making the default graphql can be dangerous, so make the default optional if necessary.

Suggested change
return this.captureGraphQLException(
if (!this.options.withGraphql) return this.captureException(scope, exception);
return this.captureGraphQLException(

Copy link
Owner

@mentos1386 mentos1386 Feb 10, 2020

Choose a reason for hiding this comment

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

I wouldn't go with the default, and also try to avoid adding withGraphql option.

Are there any other contexts that are added by other modules, in the same way as graphql?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed :)

const data = Handlers.parseRequest(<any>{}, gqlHost.getContext(), this.options);
const data = Handlers.parseRequest(
<any>{},
gqlHost.getContext(),

Choose a reason for hiding this comment

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

gqlHost.getContext() isn't the req object in nest by default, so it shouldn't be used as is here.
This caused missing request metadata in sentry until now when using nest-raven with graphql.
I suggest

const context = gqlHost.getContext();

const data = Handlers.parseRequest(
      <any>{},
      context.req || context,
      this.options,
    );

Since it is common to add a req field to the context while configuring nest-graphql, but it is by no means the default behaviour so the current code is provided as fallback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed :)

@mentos1386
Copy link
Owner

Hey @9renpoto! Thanks for this PR, greatly appreciated.

In the future, is nice to not commit code style changes. As it makes harder to review actual code changes.

In general it looks OK. Left you couple of comments, also look at @orzarchi comment.

});
expect(result.errors).toMatchInlineSnapshot(`
Array [
[GraphQLError: [object Object]],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@9renpoto
Copy link
Collaborator Author

@mentos1386 @orzarchi thank you reviews, fixed it :)

level?: Sentry.Severity;
context?: 'Http' | 'Ws' | 'Rpc' | "GraphQL";
level?: Severity;
withGraphQL?: boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add new options

@9renpoto
Copy link
Collaborator Author

9renpoto commented Mar 9, 2020

@mentos1386 Hello. Work additional as needed. than you :)

@mentos1386
Copy link
Owner

@9renpoto can you fix that merge conflict and i'll merge this.

I'm still not fully in to adding withGraphql option. I'll make a an issue after i merge this and it can be discussed there.

@mentos1386 mentos1386 merged commit c15ed94 into mentos1386:master Mar 10, 2020
@mentos1386
Copy link
Owner

Thanks @9renpoto!

@9renpoto 9renpoto deleted the feature/graphql branch March 10, 2020 14:20
@9renpoto 9renpoto modified the milestones: v7.0.0, v6.0.0 May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to nestjs 6.7.0 GraphQL improvements
4 participants