@constructive-io/graphql-codegen 2.21.0 → 2.22.1
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/cli/codegen/barrel.d.ts +4 -1
- package/cli/codegen/barrel.js +18 -12
- package/cli/codegen/client.js +33 -0
- package/cli/codegen/custom-mutations.d.ts +4 -0
- package/cli/codegen/custom-mutations.js +39 -13
- package/cli/codegen/custom-queries.d.ts +4 -0
- package/cli/codegen/custom-queries.js +36 -11
- package/cli/codegen/gql-ast.js +9 -5
- package/cli/codegen/index.js +35 -7
- package/cli/codegen/mutations.d.ts +2 -0
- package/cli/codegen/mutations.js +87 -23
- package/cli/codegen/orm/barrel.js +4 -2
- package/cli/codegen/orm/index.js +17 -0
- package/cli/codegen/orm/input-types-generator.js +83 -29
- package/cli/codegen/orm/model-generator.js +6 -4
- package/cli/codegen/queries.js +36 -27
- package/cli/codegen/scalars.d.ts +6 -4
- package/cli/codegen/scalars.js +17 -9
- package/cli/codegen/schema-types-generator.d.ts +26 -0
- package/cli/codegen/schema-types-generator.js +365 -0
- package/cli/codegen/ts-ast.d.ts +3 -1
- package/cli/codegen/ts-ast.js +2 -2
- package/cli/codegen/type-resolver.d.ts +52 -6
- package/cli/codegen/type-resolver.js +97 -19
- package/cli/codegen/types.d.ts +7 -4
- package/cli/codegen/types.js +94 -41
- package/cli/codegen/utils.d.ts +20 -2
- package/cli/codegen/utils.js +32 -7
- package/cli/commands/generate-orm.js +5 -5
- package/cli/commands/generate.d.ts +4 -1
- package/cli/commands/generate.js +27 -8
- package/cli/introspect/transform-schema.d.ts +33 -21
- package/cli/introspect/transform-schema.js +31 -21
- package/esm/cli/codegen/barrel.d.ts +4 -1
- package/esm/cli/codegen/barrel.js +18 -12
- package/esm/cli/codegen/client.js +33 -0
- package/esm/cli/codegen/custom-mutations.d.ts +4 -0
- package/esm/cli/codegen/custom-mutations.js +40 -14
- package/esm/cli/codegen/custom-queries.d.ts +4 -0
- package/esm/cli/codegen/custom-queries.js +37 -12
- package/esm/cli/codegen/gql-ast.js +10 -6
- package/esm/cli/codegen/index.js +35 -7
- package/esm/cli/codegen/mutations.d.ts +2 -0
- package/esm/cli/codegen/mutations.js +88 -24
- package/esm/cli/codegen/orm/barrel.js +4 -2
- package/esm/cli/codegen/orm/index.js +17 -0
- package/esm/cli/codegen/orm/input-types-generator.js +83 -29
- package/esm/cli/codegen/orm/model-generator.js +7 -5
- package/esm/cli/codegen/queries.js +37 -28
- package/esm/cli/codegen/scalars.d.ts +6 -4
- package/esm/cli/codegen/scalars.js +16 -8
- package/esm/cli/codegen/schema-types-generator.d.ts +26 -0
- package/esm/cli/codegen/schema-types-generator.js +362 -0
- package/esm/cli/codegen/ts-ast.d.ts +3 -1
- package/esm/cli/codegen/ts-ast.js +2 -2
- package/esm/cli/codegen/type-resolver.d.ts +52 -6
- package/esm/cli/codegen/type-resolver.js +97 -20
- package/esm/cli/codegen/types.d.ts +7 -4
- package/esm/cli/codegen/types.js +95 -41
- package/esm/cli/codegen/utils.d.ts +20 -2
- package/esm/cli/codegen/utils.js +31 -7
- package/esm/cli/commands/generate-orm.js +5 -5
- package/esm/cli/commands/generate.d.ts +4 -1
- package/esm/cli/commands/generate.js +27 -8
- package/esm/cli/introspect/transform-schema.d.ts +33 -21
- package/esm/cli/introspect/transform-schema.js +31 -21
- package/esm/types/schema.d.ts +2 -0
- package/package.json +8 -7
- package/types/schema.d.ts +2 -0
- package/__tests__/codegen/input-types-generator.test.d.ts +0 -1
- package/__tests__/codegen/input-types-generator.test.js +0 -635
- package/__tests__/codegen/react-query-optional.test.d.ts +0 -1
- package/__tests__/codegen/react-query-optional.test.js +0 -292
- package/cli/codegen/filters.d.ts +0 -27
- package/cli/codegen/filters.js +0 -357
- package/cli/codegen/orm/input-types-generator.test.d.ts +0 -1
- package/cli/codegen/orm/input-types-generator.test.js +0 -75
- package/cli/codegen/orm/select-types.test.d.ts +0 -11
- package/cli/codegen/orm/select-types.test.js +0 -22
- package/cli/introspect/transform-schema.test.d.ts +0 -1
- package/cli/introspect/transform-schema.test.js +0 -67
- package/esm/__tests__/codegen/input-types-generator.test.d.ts +0 -1
- package/esm/__tests__/codegen/input-types-generator.test.js +0 -633
- package/esm/__tests__/codegen/react-query-optional.test.d.ts +0 -1
- package/esm/__tests__/codegen/react-query-optional.test.js +0 -290
- package/esm/cli/codegen/filters.d.ts +0 -27
- package/esm/cli/codegen/filters.js +0 -351
- package/esm/cli/codegen/orm/input-types-generator.test.d.ts +0 -1
- package/esm/cli/codegen/orm/input-types-generator.test.js +0 -73
- package/esm/cli/codegen/orm/select-types.test.d.ts +0 -11
- package/esm/cli/codegen/orm/select-types.test.js +0 -21
- package/esm/cli/introspect/transform-schema.test.d.ts +0 -1
- package/esm/cli/introspect/transform-schema.test.js +0 -65
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Jest globals - no import needed
|
|
2
|
-
import { generateInputTypesFile } from './input-types-generator';
|
|
3
|
-
const uuidType = { gqlType: 'UUID', isArray: false };
|
|
4
|
-
const stringType = { gqlType: 'String', isArray: false };
|
|
5
|
-
function createTable(table) {
|
|
6
|
-
return {
|
|
7
|
-
name: table.name,
|
|
8
|
-
fields: table.fields ?? [],
|
|
9
|
-
relations: table.relations ?? {
|
|
10
|
-
belongsTo: [],
|
|
11
|
-
hasOne: [],
|
|
12
|
-
hasMany: [],
|
|
13
|
-
manyToMany: [],
|
|
14
|
-
},
|
|
15
|
-
query: table.query,
|
|
16
|
-
inflection: table.inflection,
|
|
17
|
-
constraints: table.constraints,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
describe('input-types-generator', () => {
|
|
21
|
-
it('emits relation helpers and select types with related names', () => {
|
|
22
|
-
const userTable = createTable({
|
|
23
|
-
name: 'User',
|
|
24
|
-
fields: [
|
|
25
|
-
{ name: 'id', type: uuidType },
|
|
26
|
-
{ name: 'name', type: stringType },
|
|
27
|
-
],
|
|
28
|
-
relations: {
|
|
29
|
-
belongsTo: [],
|
|
30
|
-
hasOne: [],
|
|
31
|
-
hasMany: [
|
|
32
|
-
{
|
|
33
|
-
fieldName: 'posts',
|
|
34
|
-
isUnique: false,
|
|
35
|
-
referencedByTable: 'Post',
|
|
36
|
-
type: null,
|
|
37
|
-
keys: [],
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
manyToMany: [],
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
const postTable = createTable({
|
|
44
|
-
name: 'Post',
|
|
45
|
-
fields: [
|
|
46
|
-
{ name: 'id', type: uuidType },
|
|
47
|
-
{ name: 'title', type: stringType },
|
|
48
|
-
],
|
|
49
|
-
relations: {
|
|
50
|
-
belongsTo: [
|
|
51
|
-
{
|
|
52
|
-
fieldName: 'author',
|
|
53
|
-
isUnique: false,
|
|
54
|
-
referencesTable: 'User',
|
|
55
|
-
type: null,
|
|
56
|
-
keys: [],
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
hasOne: [],
|
|
60
|
-
hasMany: [],
|
|
61
|
-
manyToMany: [],
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
const result = generateInputTypesFile(new Map(), new Set(), [userTable, postTable]);
|
|
65
|
-
expect(result.content).toContain('export interface ConnectionResult<T>');
|
|
66
|
-
expect(result.content).toContain('export interface UserRelations');
|
|
67
|
-
expect(result.content).toContain('posts?: ConnectionResult<Post>');
|
|
68
|
-
expect(result.content).toContain('export type UserWithRelations = User & UserRelations;');
|
|
69
|
-
expect(result.content).toContain('posts?: boolean | {');
|
|
70
|
-
expect(result.content).toContain('orderBy?: PostsOrderBy[];');
|
|
71
|
-
expect(result.content).toContain('author?: boolean | { select?: UserSelect };');
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-level tests for select-types.ts
|
|
3
|
-
*
|
|
4
|
-
* These tests verify the compile-time type inference behavior.
|
|
5
|
-
* The TypeScript compiler validates these types during build.
|
|
6
|
-
*
|
|
7
|
-
* Note: Type-only tests using expectTypeOf have been removed as they
|
|
8
|
-
* are not compatible with Jest. The TypeScript compiler validates
|
|
9
|
-
* these types at compile time via the type assertions below.
|
|
10
|
-
*/
|
|
11
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-level tests for select-types.ts
|
|
3
|
-
*
|
|
4
|
-
* These tests verify the compile-time type inference behavior.
|
|
5
|
-
* The TypeScript compiler validates these types during build.
|
|
6
|
-
*
|
|
7
|
-
* Note: Type-only tests using expectTypeOf have been removed as they
|
|
8
|
-
* are not compatible with Jest. The TypeScript compiler validates
|
|
9
|
-
* these types at compile time via the type assertions below.
|
|
10
|
-
*/
|
|
11
|
-
// Compile-time type check: verify the inferred type matches expected structure
|
|
12
|
-
const _typeCheck = {};
|
|
13
|
-
const _excludedTypeCheck = {};
|
|
14
|
-
// Dummy test to satisfy Jest
|
|
15
|
-
describe('InferSelectResult', () => {
|
|
16
|
-
it('type assertions compile correctly', () => {
|
|
17
|
-
// If this file compiles, the type tests pass
|
|
18
|
-
expect(true).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Jest globals - no import needed
|
|
2
|
-
import { getTableOperationNames, getCustomOperations, isTableOperation, } from './transform-schema';
|
|
3
|
-
describe('transform-schema table operation filtering', () => {
|
|
4
|
-
const dummyReturnType = { kind: 'SCALAR', name: 'String' };
|
|
5
|
-
it('detects table operations and update/delete patterns', () => {
|
|
6
|
-
const tableOps = getTableOperationNames([
|
|
7
|
-
{
|
|
8
|
-
name: 'User',
|
|
9
|
-
query: {
|
|
10
|
-
all: 'users',
|
|
11
|
-
one: 'user',
|
|
12
|
-
create: 'createUser',
|
|
13
|
-
update: 'updateUser',
|
|
14
|
-
delete: 'deleteUser',
|
|
15
|
-
},
|
|
16
|
-
inflection: { tableType: 'User' },
|
|
17
|
-
},
|
|
18
|
-
]);
|
|
19
|
-
const updateByEmail = {
|
|
20
|
-
name: 'updateUserByEmail',
|
|
21
|
-
kind: 'mutation',
|
|
22
|
-
args: [],
|
|
23
|
-
returnType: dummyReturnType,
|
|
24
|
-
};
|
|
25
|
-
const login = {
|
|
26
|
-
name: 'login',
|
|
27
|
-
kind: 'mutation',
|
|
28
|
-
args: [],
|
|
29
|
-
returnType: dummyReturnType,
|
|
30
|
-
};
|
|
31
|
-
expect(isTableOperation(updateByEmail, tableOps)).toBe(true);
|
|
32
|
-
expect(isTableOperation(login, tableOps)).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
it('filters out table operations from custom list', () => {
|
|
35
|
-
const tableOps = getTableOperationNames([
|
|
36
|
-
{
|
|
37
|
-
name: 'User',
|
|
38
|
-
query: {
|
|
39
|
-
all: 'users',
|
|
40
|
-
one: 'user',
|
|
41
|
-
create: 'createUser',
|
|
42
|
-
update: 'updateUser',
|
|
43
|
-
delete: 'deleteUser',
|
|
44
|
-
},
|
|
45
|
-
inflection: { tableType: 'User' },
|
|
46
|
-
},
|
|
47
|
-
]);
|
|
48
|
-
const operations = [
|
|
49
|
-
{
|
|
50
|
-
name: 'users',
|
|
51
|
-
kind: 'query',
|
|
52
|
-
args: [],
|
|
53
|
-
returnType: dummyReturnType,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'login',
|
|
57
|
-
kind: 'mutation',
|
|
58
|
-
args: [],
|
|
59
|
-
returnType: dummyReturnType,
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
const customOps = getCustomOperations(operations, tableOps);
|
|
63
|
-
expect(customOps.map((op) => op.name)).toEqual(['login']);
|
|
64
|
-
});
|
|
65
|
-
});
|