-
Notifications
You must be signed in to change notification settings - Fork 2k
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
isSpecifiedDirective should not assume Directive type #1837
isSpecifiedDirective should not assume Directive type #1837
Conversation
@Cito Thanks for PR 👍 graphql-js/src/type/directives.js Lines 32 to 34 in ce832ee
Also, note that graphql-js/src/type/directives.js Lines 190 to 192 in ce832ee
So if you need to test if some value is standard directive you would do: if (isDirective(value) && isSpecifiedDirective(value)) {
// ...
} What do you think? |
The problem was that it was unclear to me that this should be considered a non-overlapping, additional check, and not as a standalone check. To me a standalone check would be more intuitive. I was also looking at these four tests which run the predicate against various garbage. These tests should be removed as superfluous and misleading if the input is supposed to be a directive anyway. Otherwise, a test with Just had a look at |
You added them in #1781 😄
export function isIntrospectionType(type: mixed): boolean %checks {
return (
isNamedType(type) &&
My idea was that type checks (e.g. But since
Can you please change it to |
These can now both be used as standalone tests. Also added some unit tests for these predicates.
Good that git always reminds us of our past sins 😂 I've pushed a new commit that hopefully is better. Both predicates now work as standalone checks. |
Btw, there is another issue here that I don't quite understand. These checks could all be simplified by using But what exactly would break here when using
|
@Cito Merged 🎉 Thanks for PR 👍
By default flow assumes that function arguments are mutable so it can be sure that |
Thanks for the explanation. Normally you would expect to see more errors when adding "strict", but you're right, in this case the error disappears because with "strict" flow can assume function parameters are const. Setting "strict" seems to pay off, good decision. 👍 |
Fixes graphql#2153 Previous disscussion: graphql#1837 (comment)
…es (#2196) Fixes #2153 Previous disscussion: #1837 (comment)
isSpecifiedDirective should not just check the name property, but also the type