Skip to content

Replace instanceof checks with their respective predicates#1518

Merged
trevor-scheer merged 3 commits intomasterfrom
trevor/remove-graphql-instanceof
Sep 9, 2019
Merged

Replace instanceof checks with their respective predicates#1518
trevor-scheer merged 3 commits intomasterfrom
trevor/remove-graphql-instanceof

Conversation

@trevor-scheer
Copy link
Copy Markdown
Contributor

@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.

true
);
const isOptional = !(
type instanceof GraphQLNonNull || type instanceof GraphQLNonNull
Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread packages/apollo-language-server/src/languageProvider.ts Outdated
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