@model-ts/graphql 7.3.0 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +22 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/GraphQL.d.ts +1 -0
- package/dist/GraphQL.d.ts.map +1 -1
- package/dist/GraphQL.js +1 -0
- package/dist/GraphQL.js.map +1 -1
- package/dist/Registry.d.ts +1 -1
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Scalars.d.ts +24 -2
- package/dist/Scalars.d.ts.map +1 -1
- package/dist/Scalars.js +27 -3
- package/dist/Scalars.js.map +1 -1
- package/package.json +1 -1
- package/src/GraphQL.ts +1 -0
- package/src/Registry.ts +8 -5
- package/src/Scalars.ts +36 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @model-ts/graphql
|
|
2
2
|
|
|
3
|
+
## 7.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6032bfa: Let the JSON scalar declare `@specifiedBy`. `jsonScalar({ specifiedByURL, description })` is exported and returns the built-in JSON scalar with that metadata. Registering `"JSON"` with an annotated `JSONValue`, as in `GraphQL.scalar("JSON", JSONValue.annotate({ specifiedByURL }))`, now keeps the built-in JSON parsing (enum literals rejected at any depth, the ECMA-404 description by default) and takes the annotations' metadata. `Register` infers a schema of unknown values, such as `JSONValue`, as a scalar.
|
|
8
|
+
|
|
3
9
|
## 7.3.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -874,6 +874,27 @@ valid Date or parseable date string and serializes to ISO.
|
|
|
874
874
|
`graphql-type-json` convention. Literal JSON rejects unquoted enum values. For
|
|
875
875
|
stricter validation, use `Schema.Json.annotate({ graphqlType: "JSON" })`.
|
|
876
876
|
|
|
877
|
+
To give the JSON scalar a `@specifiedBy` URL or its own description, register
|
|
878
|
+
it with an annotated `JSONValue`. The builder keeps the built-in JSON parsing
|
|
879
|
+
and takes `specifiedByURL` and `description` from the annotations:
|
|
880
|
+
|
|
881
|
+
```ts
|
|
882
|
+
import { JSONValue } from "@model-ts/graphql"
|
|
883
|
+
import { GraphQL, type Register } from "../api/graphql.ts"
|
|
884
|
+
|
|
885
|
+
const specifiedByURL =
|
|
886
|
+
"https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf"
|
|
887
|
+
const AnnotatedJSON = JSONValue.annotate({ specifiedByURL })
|
|
888
|
+
declare module "../api/graphql.ts" {
|
|
889
|
+
interface Types extends Register<typeof AnnotatedJSON, "JSON"> {}
|
|
890
|
+
}
|
|
891
|
+
export const JSONType = GraphQL.scalar("JSON", AnnotatedJSON)
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
The schema then prints `scalar JSON @specifiedBy(url: "...")`. To set the
|
|
895
|
+
metadata on the scalar itself, pass `jsonScalar({ specifiedByURL, description })`
|
|
896
|
+
as the third argument; it has the same parsing as the built-in scalar.
|
|
897
|
+
|
|
877
898
|
Custom scalars pair a registered name with a Schema codec:
|
|
878
899
|
|
|
879
900
|
`examples/custom-scalar.ts`
|
|
@@ -1274,6 +1295,7 @@ functions such as `executor` are separate exports, not builder methods.
|
|
|
1274
1295
|
| `ExecutionResult`, `FormattedExecutionResult` | Direct graphql-js results and formatted executor results |
|
|
1275
1296
|
| `ErrorReporter` | Optional service for masked-failure telemetry |
|
|
1276
1297
|
| `ID`, `DateTime`, `JSONValue` | Built-in input schemas |
|
|
1298
|
+
| `jsonScalar({ specifiedByURL?, description? })` | The built-in JSON scalar, with its own metadata |
|
|
1277
1299
|
| `id`, `input`, `defaulted` | Package-level schema annotation helpers |
|
|
1278
1300
|
| `Connection`, `Edge`, `PageInfo`, `ConnectionArgs` | Structural pagination types |
|
|
1279
1301
|
| `@model-ts/graphql/Testing` | Test clients, the graphql tag, and normalized snapshots |
|