Skip to content

Commit a13ab9b

Browse files
authored
fix: remove injections from prisma output types (#597)
Remove injections from generated output types for prisma operations. #### Motivation and context Generated types fail validations (_injection not allowed in output types_). #### Migration notes _No changes needed_. ### Checklist - [x] The change come with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change
1 parent a2c2a80 commit a13ab9b

File tree

48 files changed

+16715
-16300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+16715
-16300
lines changed

typegate/tests/runtimes/typegate/__snapshots__/typegate_runtime_test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ snapshot[`typegate: find available operations 1`] = `
523523
format: null,
524524
optional: false,
525525
runtime: "prisma",
526-
title: "_317_messagesWithNestedCount[]",
526+
title: "_336_messagesWithNestedCount[]",
527527
type: "list",
528528
},
529529
outputItem: {
@@ -610,7 +610,7 @@ snapshot[`typegate: find available operations 1`] = `
610610
format: null,
611611
optional: false,
612612
runtime: "prisma",
613-
title: "_22_user_identity[]",
613+
title: "list_324",
614614
type: "list",
615615
},
616616
},
@@ -661,7 +661,7 @@ snapshot[`typegate: find available operations 1`] = `
661661
format: null,
662662
optional: false,
663663
runtime: "prisma",
664-
title: "_26_messages[]",
664+
title: "list_333",
665665
type: "list",
666666
},
667667
},

typegraph/core/src/runtimes/prisma/relationship/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ impl PrismaLink {
9595
type_ref.set("target_field", target_field);
9696
}
9797
let res = type_ref.build()?;
98-
eprintln!("type_ref: {:?}", res);
9998
Ok(res)
10099
}
101100
}

typegraph/core/src/runtimes/prisma/type_generation/out_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::runtimes::prisma::errors;
77
use crate::runtimes::prisma::model::Property;
88
use crate::t::{self, ConcreteTypeBuilder, TypeBuilder};
99
use crate::types::TypeId;
10-
use crate::utils::remove_injection;
10+
use crate::utils::remove_injections_recursive;
1111

1212
use super::{Cardinality, TypeGen};
1313

@@ -63,7 +63,7 @@ impl TypeGen for OutType {
6363
builder.prop(key, out_type);
6464
}
6565
Property::Scalar(prop) => {
66-
builder.prop(key, remove_injection(prop.wrapper_type_id)?);
66+
builder.prop(key, remove_injections_recursive(prop.wrapper_type_id)?);
6767
}
6868
Property::Unmanaged(type_id) => {
6969
// just forward the original type

typegraph/core/src/runtimes/prisma/type_generation/snapshots/typegraph_core__runtimes__prisma__type_generation__test__aggregate Post out.snap

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
source: typegraph/core/src/runtimes/prisma/type_generation/mod.rs
33
expression: tp.print(out)
44
---
5-
root: struct #49
6-
├─ [_avg]: struct '_Post_NumberAgg_avg' #43
7-
│ └─ [id]: optional #42
8-
│ └─ item: float #41
9-
├─ [_count]: struct '_Post_AggrCount' #40
10-
│ ├─ [_all]: optional #39
11-
│ │ └─ item: integer #38
12-
│ ├─ [author]: optional #39
13-
│ │ └─ item: integer #38
14-
│ ├─ [id]: optional #39
15-
│ │ └─ item: integer #38
16-
│ └─ [title]: optional #39
17-
│ └─ item: integer #38
18-
├─ [_max]: struct '_Post_NumberAgg' #48
19-
│ └─ [id]: optional #47
20-
│ └─ item: integer #46
21-
├─ [_min]: struct '_Post_NumberAgg' #48
22-
│ └─ [id]: optional #47
23-
│ └─ item: integer #46
24-
└─ [_sum]: struct '_Post_NumberAgg' #48
25-
└─ [id]: optional #47
26-
└─ item: integer #46
5+
root: struct #51
6+
├─ [_avg]: struct '_Post_NumberAgg_avg' #45
7+
│ └─ [id]: optional #44
8+
│ └─ item: float #43
9+
├─ [_count]: struct '_Post_AggrCount' #42
10+
│ ├─ [_all]: optional #41
11+
│ │ └─ item: integer #40
12+
│ ├─ [author]: optional #41
13+
│ │ └─ item: integer #40
14+
│ ├─ [id]: optional #41
15+
│ │ └─ item: integer #40
16+
│ └─ [title]: optional #41
17+
│ └─ item: integer #40
18+
├─ [_max]: struct '_Post_NumberAgg' #50
19+
│ └─ [id]: optional #49
20+
│ └─ item: integer #48
21+
├─ [_min]: struct '_Post_NumberAgg' #50
22+
│ └─ [id]: optional #49
23+
│ └─ item: integer #48
24+
└─ [_sum]: struct '_Post_NumberAgg' #50
25+
└─ [id]: optional #49
26+
└─ item: integer #48
2727

Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
---
22
source: typegraph/core/src/runtimes/prisma/type_generation/mod.rs
3-
expression: "tree::PrintOptions::new().indent_size(3).print(out)"
3+
expression: tp.print(out)
44
---
5-
root: struct #16
6-
├─ [_avg]: struct '_Record_NumberAgg_avg' #10
7-
│ └─ [age]: optional #9
8-
│ └─ item: float #8
9-
├─ [_count]: struct '_Record_AggrCount' #7
10-
│ ├─ [_all]: optional #6
11-
│ │ └─ item: integer #5
12-
│ ├─ [age]: optional #6
13-
│ │ └─ item: integer #5
14-
│ ├─ [id]: optional #6
15-
│ │ └─ item: integer #5
16-
│ └─ [name]: optional #6
17-
│ └─ item: integer #5
18-
├─ [_max]: struct '_Record_NumberAgg' #15
19-
│ └─ [age]: optional #14
20-
│ └─ item: integer #13
21-
├─ [_min]: struct '_Record_NumberAgg' #15
22-
│ └─ [age]: optional #14
23-
│ └─ item: integer #13
24-
└─ [_sum]: struct '_Record_NumberAgg' #15
25-
└─ [age]: optional #14
26-
└─ item: integer #13
5+
root: struct #18
6+
├─ [_avg]: struct '_Record_NumberAgg_avg' #12
7+
│ └─ [age]: optional #11
8+
│ └─ item: float #10
9+
├─ [_count]: struct '_Record_AggrCount' #9
10+
│ ├─ [_all]: optional #8
11+
│ │ └─ item: integer #7
12+
│ ├─ [age]: optional #8
13+
│ │ └─ item: integer #7
14+
│ ├─ [created_at]: optional #8
15+
│ │ └─ item: integer #7
16+
│ ├─ [id]: optional #8
17+
│ │ └─ item: integer #7
18+
│ └─ [name]: optional #8
19+
│ └─ item: integer #7
20+
├─ [_max]: struct '_Record_NumberAgg' #17
21+
│ └─ [age]: optional #16
22+
│ └─ item: integer #15
23+
├─ [_min]: struct '_Record_NumberAgg' #17
24+
│ └─ [age]: optional #16
25+
│ └─ item: integer #15
26+
└─ [_sum]: struct '_Record_NumberAgg' #17
27+
└─ [age]: optional #16
28+
└─ item: integer #15
2729

typegraph/core/src/runtimes/prisma/type_generation/snapshots/typegraph_core__runtimes__prisma__type_generation__test__aggregate User out.snap

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
source: typegraph/core/src/runtimes/prisma/type_generation/mod.rs
33
expression: tp.print(out)
44
---
5-
root: struct #37
6-
├─ [_avg]: struct '_User_NumberAgg_avg' #31
7-
│ └─ [id]: optional #30
8-
│ └─ item: float #29
9-
├─ [_count]: struct '_User_AggrCount' #28
10-
│ ├─ [_all]: optional #27
11-
│ │ └─ item: integer #26
12-
│ ├─ [id]: optional #27
13-
│ │ └─ item: integer #26
14-
│ ├─ [name]: optional #27
15-
│ │ └─ item: integer #26
16-
│ └─ [posts]: optional #27
17-
│ └─ item: integer #26
18-
├─ [_max]: struct '_User_NumberAgg' #36
19-
│ └─ [id]: optional #35
20-
│ └─ item: integer #34
21-
├─ [_min]: struct '_User_NumberAgg' #36
22-
│ └─ [id]: optional #35
23-
│ └─ item: integer #34
24-
└─ [_sum]: struct '_User_NumberAgg' #36
25-
└─ [id]: optional #35
26-
└─ item: integer #34
5+
root: struct #39
6+
├─ [_avg]: struct '_User_NumberAgg_avg' #33
7+
│ └─ [id]: optional #32
8+
│ └─ item: float #31
9+
├─ [_count]: struct '_User_AggrCount' #30
10+
│ ├─ [_all]: optional #29
11+
│ │ └─ item: integer #28
12+
│ ├─ [id]: optional #29
13+
│ │ └─ item: integer #28
14+
│ ├─ [name]: optional #29
15+
│ │ └─ item: integer #28
16+
│ └─ [posts]: optional #29
17+
│ └─ item: integer #28
18+
├─ [_max]: struct '_User_NumberAgg' #38
19+
│ └─ [id]: optional #37
20+
│ └─ item: integer #36
21+
├─ [_min]: struct '_User_NumberAgg' #38
22+
│ └─ [id]: optional #37
23+
│ └─ item: integer #36
24+
└─ [_sum]: struct '_User_NumberAgg' #38
25+
└─ [id]: optional #37
26+
└─ item: integer #36
2727

0 commit comments

Comments
 (0)