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

fix(graphql): similar directive sdls on multiple fields fail #2559

Merged
merged 4 commits into from Feb 6, 2023

Conversation

harm-less
Copy link
Contributor

@harm-less harm-less commented Dec 16, 2022

Similar directive sdls on multiple fields fail if applied to the same target. I stumbled upon this while migrating from NestJS 8 to 9. It still baffles me how this could have happened from all the code I analysed and read, but I guess there's a good underlying reason for this bug.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

I ran into a problem in which the following code doesn't not register all applied directives:

@Resolver(() => TypeSomething)
export class TwoResolversWithSimilarDirectives {

	@Query((returns) => TypeSomething)
	@Directive('@hasPermission(permissions: APP_ACCOUNTS_READ)')
	@Directive('@limit')
	async resolver1() {
		return {}
	}

	@Query((returns) => TypeSomething)
	@Directive('@hasPermission(permissions: APP_ACCOUNTS_READ)')
	@Directive('@limit')
	async resolver2() {
		return {}
	}
}

As can be seen, I've got 2 resolver methods in 1 target both of which the same SDLs are applied to. Yet, what currently happens is that the second resolver only has one directive applied to the GraphQL schema and not both as intended.

Issue Number: N/A

What is the new behavior?

All expected directives are applied to the corresponding fields

Does this PR introduce a breaking change?

  • Yes
  • No

Similar directive sdls on multiple fields fail if applied to the same target
Co-authored-by: Kashif Ahmed <33416799+ProKashif@users.noreply.github.com>
@kamilmysliwiec
Copy link
Member

LGTM

@kamilmysliwiec kamilmysliwiec merged commit 90727cf into nestjs:master Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants