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

allow toString directive (check isNode on merge if inherited from prototype) #5973

Merged

Conversation

lesleydreyer
Copy link
Contributor

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.

Description

I was trying to make a toString directive and makeExecutableSchema was failing.

It wasn't working because it creates an object (mergedResultMap in function mergeGraphQLNodes) and objects have an inherited toString method. So it was finding that toString exists in the map because it was the inherited object function, not a directive. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty#direct_vs._inherited_properties)

So I thought maybe when merging the directive it could check if it exists and if it's an inherited property and not a node, then set to undefined so it can proceed to create the directive node instead of the inherited object function.

Related #5967

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Screenshots/Sandbox (if appropriate/relevant):

Codesandbox to show the error https://codesandbox.io/p/devbox/brave-visvesvaraya-49xx8m

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can
reproduce. Please also list any relevant details for your test configuration

  • Unit test
  • Patched into my project

Test Environment:

  • OS:
  • @graphql-tools/...:
  • NodeJS:

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose
the solution you did and what alternatives you considered, etc...

@ardatan ardatan merged commit 0b43440 into ardatan:master Mar 11, 2024
28 checks passed
@ardatan
Copy link
Owner

ardatan commented Mar 11, 2024

Thanks for the PR!

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