Skip to content

Commit abb835c

Browse files
authored
Add ChilliCream UnsignedByte scalar (#48)
* Add ChilliCream Byte scalar * Add note about .NET type * Remove references to .NET * Rename to UnsignedByte
1 parent ec26c47 commit abb835c

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# UnsignedByte — GraphQL Custom Scalar
2+
3+
Author – ChilliCream
4+
5+
Date – 2025-12-29
6+
7+
**License and Copyright**
8+
9+
Copyright © GraphQL contributors. This specification is licensed under
10+
[OWFa 1.0](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owfa-1-0).
11+
12+
# Overview
13+
14+
The `UnsignedByte` scalar type represents an unsigned 8-bit integer. It is
15+
intended for scenarios where values are constrained to the range 0 to 255, such
16+
as representing color channel values (RGB), small counters, or byte-level data.
17+
18+
Unlike the built-in `Int` scalar which represents signed 32-bit integers,
19+
`UnsignedByte` provides stronger type safety and validation for values that must
20+
fit within an unsigned 8-bit range.
21+
22+
# Recommended name
23+
24+
The recommended name for this scalar is `UnsignedByte`.
25+
26+
# Result spec
27+
28+
An `UnsignedByte` scalar must serialize to an integer value in the range 0 to
29+
255 (inclusive).
30+
31+
## Examples
32+
33+
These are valid result values:
34+
35+
| Value | Explanation |
36+
| ----- | ---------------------------- |
37+
| `0` | Minimum unsigned byte value. |
38+
| `255` | Maximum unsigned byte value. |
39+
| `128` | Mid-range value. |
40+
41+
These are invalid result values:
42+
43+
| Value | Why is it invalid |
44+
| ------- | ------------------------------------------ |
45+
| `-1` | Negative values are not allowed. |
46+
| `256` | Exceeds maximum unsigned byte value (255). |
47+
| `3.14` | Fractional values are not allowed. |
48+
| `"128"` | Must be a number, not a string. |
49+
50+
# Input spec
51+
52+
An `UnsignedByte` scalar accepts integer values in the range 0 to 255
53+
(inclusive), both as GraphQL literals and as JSON input values.
54+
55+
Implementations should validate:
56+
57+
- Value is an integer (no fractional component)
58+
- Value is between 0 and 255 (inclusive)
59+
- Value is not negative
60+
61+
## Examples
62+
63+
Valid input values:
64+
65+
GraphQL Literal:
66+
67+
```graphql
68+
mutation {
69+
setColor(red: 255, green: 128, blue: 0) {
70+
id
71+
}
72+
}
73+
```
74+
75+
JSON input:
76+
77+
```json
78+
{
79+
"red": 255,
80+
"green": 128,
81+
"blue": 0
82+
}
83+
```
84+
85+
Invalid input values:
86+
87+
| Value | Why is it invalid |
88+
| ------- | ------------------------------------------ |
89+
| `-1` | Negative values are not allowed. |
90+
| `256` | Exceeds maximum unsigned byte value (255). |
91+
| `3.14` | Fractional values are not allowed. |
92+
| `"128"` | Must be a number, not a string. |
93+
94+
# References
95+
96+
- [GraphQL Specification - Int](https://spec.graphql.org/September2025/#sec-Int)
97+
— Built-in integer scalar type

0 commit comments

Comments
 (0)