@vladimirdev635/gql-codegen 0.0.112 → 0.0.115

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/schema/shared.js CHANGED
@@ -15,11 +15,30 @@ export const inputTypeSchema = z.discriminatedUnion('_type', [
15
15
  $ref: z.string(),
16
16
  }),
17
17
  ]);
18
- export const literalSchema = z.union([
19
- z.string(),
20
- z.int(),
21
- z.float32(),
22
- z.boolean(),
18
+ export const literalSchema = z.discriminatedUnion('_type', [
19
+ z.object({
20
+ _type: z.literal('string'),
21
+ value: z.string(),
22
+ }),
23
+ z.object({
24
+ _type: z.literal('enum-value'),
25
+ value: z.string(),
26
+ }),
27
+ z.object({
28
+ _type: z.literal('null'),
29
+ }),
30
+ z.object({
31
+ _type: z.literal('int'),
32
+ value: z.number(),
33
+ }),
34
+ z.object({
35
+ _type: z.literal('float'),
36
+ value: z.number(),
37
+ }),
38
+ z.object({
39
+ _type: z.literal('boolean'),
40
+ value: z.boolean(),
41
+ }),
23
42
  ]);
24
43
  export const arrayLiteralSchema = z.union([
25
44
  z.array(z.string()),
@@ -30,12 +49,12 @@ export const arrayLiteralSchema = z.union([
30
49
  export const inputLiteralSpecSchema = z.object({
31
50
  _type: z.literal('literal'),
32
51
  type: inputTypeSchema,
33
- defaultValue: literalSchema.optional().nullable(),
52
+ defaultValue: literalSchema.optional(),
34
53
  });
35
54
  export const inputArraySpecSchema = z.object({
36
55
  _type: z.literal('array'),
37
56
  nullable: z.boolean(),
38
- defaultValue: arrayLiteralSchema.optional().nullable(),
57
+ defaultValue: arrayLiteralSchema.optional(),
39
58
  get type() {
40
59
  // eslint-disable-next-line no-use-before-define
41
60
  return inputFieldSpecSchema;
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import testServerJSON from './test-server.json' with { type: 'json' };
3
- import testClientJSON from './test-client.json' with { type: 'json' };
4
- import { serverSchema } from './server.js';
5
- import { clientSchema } from './client/root.js';
6
- describe('Server schema', () => {
7
- it('Should parse ok', () => {
8
- const result = serverSchema.safeParse(testServerJSON);
9
- expect(result.success, result.error?.message || '').toBe(true);
10
- });
11
- });
12
- describe('Client schema', () => {
13
- it('Should parse ok', () => {
14
- const result = clientSchema.safeParse(testClientJSON);
15
- expect(result.success, result.error?.message || '').toBe(true);
16
- });
17
- });