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

Replace instanceof checks with their respective predicates #1518

Merged
merged 3 commits into from
Sep 9, 2019

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Sep 9, 2019

This replaces all instanceof GraphQLXYZ checks with their respective predicate functions.

TODO:

  • Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.

@@ -157,9 +159,7 @@ export function classDeclarationForOperation(
undefined,
true
);
const isOptional = !(
type instanceof GraphQLNonNull || type instanceof GraphQLNonNull
Copy link
Contributor

Choose a reason for hiding this comment

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

Lol what even was this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@shadaj this is way back in history but can you recall if this was intentional or possibly a mistake?
Re: 58f07c4#diff-508d6e2cd0e11941b1548a2ea48a909dR139

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a mistake! I really hope there's no situation in which double-checking a type is actually needed 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

@shadaj Was removing the second check the mistake, or was that correct? Like this was originally

const isOptional = !(type instanceof GraphQLNonNull || type.ofType instanceof GraphQLNonNull);

was the ofType incorrectly removed, or was that fine to remove?

Copy link
Contributor

Choose a reason for hiding this comment

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

It was fine to remove the extra check, I believe that ofType was eliminated with changes to the IR format so only the top level type needed to be checked.

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.

3 participants