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/directives not applied to type args #98

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

felipebergamin
Copy link
Member

Description

Fix a problem that directives are not applied to type fields with arguments using directives.

Eg: foreignNodeId wasn't being applied to posts resolver

type User {
  posts(
    categories: [ID] @foreignNodeId(typename: 'Post')
  ): [Posts]
}
type Query {
  ...
}

Related Issues

Progress

Pull request checklist

  • Tests: This PR includes tests for covering the features or bug fixes (if applicable).
  • Docs: This PR updates/creates the necessary documentation.
  • CI: Make sure your Pull Request passes all CI checks. If not, clarify the motif behind that and the action plan to solve it (may reference a ticket)

How to test it

Visual reference

@felipebergamin felipebergamin marked this pull request as ready for review November 22, 2023 20:32
const [directive] = getDirective(schema, arg, directiveName) ?? [];
if (!directive) return;
// eslint-disable-next-line no-param-reassign
visitor.args = directive;
Copy link
Contributor

@DDDKnightmare DDDKnightmare Nov 22, 2023

Choose a reason for hiding this comment

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

not sure, but can't overwriting visitor.args cause problems ?

  • e.g.:
  • 1:
    • store the original value before the forEach loop
    • after the forEach loop, restore the original value, so the other mappers are not affected by the modification in the args
  • 2:
    • use a different visitor instance to visit the fields
  • 3:
    • use visitArgumentsWithDirectiveInObjectFields (same code as this block)

@felipebergamin felipebergamin merged commit 9fc15df into master Nov 22, 2023
2 checks passed
@felipebergamin felipebergamin deleted the fix/directives-not-applied-to-type-args branch November 22, 2023 20:53
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.

2 participants