Make count fields plain integers.
See original GitHub issueTL;DR
In short, I would like us to use a plain GraphQLInt
for counts
fields. I don’t really see a need to be able to format a count in MP, but would like to know if others have objections.
As we move to TypeScript and convert MP’s schema to type declarations, we’re running into the issue that for many (all?) of the counts
fields we have, the resulting type declaration is number | string | boolean
, because we are using a custom scalar rather than a specific subtype.
This type declaration is problematic because it would require us to go through hoops to cast the value as a number
in order to safely write code like:
const not_for_sale_works = artist.counts.artworks - artist.counts.for_sale_works
The TypeScript compiler will fail with the following error:
error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (13 by maintainers)
Top Results From Across the Web
COUNT function - Microsoft Support
Use the COUNT function to get the number of entries in a number field that is in a range or array of numbers....
Read more >Google Sheets COUNT and COUNTA functions with formula ...
The COUNT function in Google Sheets allows you to count the number of all cells with numbers within a specific data range.
Read more >postgresql - sql - count of `true` values - Stack Overflow
Since PostgreSQL 9.4 there's the FILTER clause, which allows for a very concise query to count the true values: select count(*) filter (where...
Read more >Python's Counter: The Pythonic Way to Count Objects
In this step-by-step tutorial, you'll learn how to use Python's Counter to count several repeated objects at once.
Read more >How to count the number of lines in a CSV file in Python?
A CSV file stores tabular data (numbers and text) in plain text. ... Each record consists of one or more fields, separated by...
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 FreeTop 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
Top GitHub Comments
@alloy Not automatically.
pageInfo
only returns cursors (startCursor
andendCursor
) as well as whether there are more page results or not. See: https://facebook.github.io/relay/graphql/connections.htm#sec-undefined.PageInfo@broskoski Good point, we can just prefix the int fields. Maybe as another nested field? E.g.
Not a big fan of the word ‘raw’, though.