New Rule: Array bang bang
See original GitHub issueMany have argued that the default behavior of Arrays in the schema should be [Obj!]!
: ex:
type Foo {
bars: [Baz!]!
}
Most of the time, when you see:
type Foo {
bars: [Baz]
}
It’s a mistake, because then null
and [null, null]
are valid values - which is most likely not the cast. Thoughts on a new rule for this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top Results From Across the Web
How does !!~ (not not tilde/bang bang tilde) alter the result of a ...
Tilde is bitwise NOT - it inverts each bit of the value. As a general rule of thumb, if you use ~ on...
Read more >Immutable Array Methods: Write Cleaner JavaScript Code
These methods will return a new array based on the operation they've ... Ruby has a nice solution to this in the way...
Read more >Javascript “Bang, Bang. I Shot You Down” - Use of Double ...
In Javascript, the exclamation mark (“!”) symbol, called a “bang,” is the logical “not” operator. Placed in front of a boolean value it...
Read more >What is the Double bang (!!) operator in JavaScript?
The ! in JavaScript, also called “bang”, is the logical “not” operator. If you place this operator in front of a boolean value,...
Read more >Understand Ruby Arrays and Common Array Methods with ...
This method iterates over an array and returns a new array that includes any ... It is a good rule to be wary...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@goldcaddy77
Lets say loading the comments of Post failed, by using
[Comment!]
you can throw anError
in the resolver for your post comments and that will be part of the response. The property comments on the Post will benull
. But you still have the partial data for the post.However if you use
[Comment!]!
and throw anError
in your post comments resolver the post will nenull
since it cannot exist without thecomments
field being anArray
.You could fix this by returning an empty
Array
and ignoring the error. However in that case the client that consumes your graphql endpoint will never know there might be some comments and e.g. you cannot hande the UI for retry etc.I hope this clarifies different use cases
This package by @morris provides a rule that checks for null list items: https://www.npmjs.com/package/graphql-schema-linter-extras It does not check for null lists. Here is the code. ISC license according to package.json.