Skip to content

Commit

Permalink
fix: remove injections from prisma output types (#597)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Natoandro committed Feb 26, 2024
1 parent a2c2a80 commit a13ab9b
Show file tree
Hide file tree
Showing 48 changed files with 16,715 additions and 16,300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ snapshot[`typegate: find available operations 1`] = `
format: null,
optional: false,
runtime: "prisma",
title: "_317_messagesWithNestedCount[]",
title: "_336_messagesWithNestedCount[]",
type: "list",
},
outputItem: {
Expand Down Expand Up @@ -610,7 +610,7 @@ snapshot[`typegate: find available operations 1`] = `
format: null,
optional: false,
runtime: "prisma",
title: "_22_user_identity[]",
title: "list_324",
type: "list",
},
},
Expand Down Expand Up @@ -661,7 +661,7 @@ snapshot[`typegate: find available operations 1`] = `
format: null,
optional: false,
runtime: "prisma",
title: "_26_messages[]",
title: "list_333",
type: "list",
},
},
Expand Down
1 change: 0 additions & 1 deletion typegraph/core/src/runtimes/prisma/relationship/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ impl PrismaLink {
type_ref.set("target_field", target_field);
}
let res = type_ref.build()?;
eprintln!("type_ref: {:?}", res);
Ok(res)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::runtimes::prisma::errors;
use crate::runtimes::prisma::model::Property;
use crate::t::{self, ConcreteTypeBuilder, TypeBuilder};
use crate::types::TypeId;
use crate::utils::remove_injection;
use crate::utils::remove_injections_recursive;

use super::{Cardinality, TypeGen};

Expand Down Expand Up @@ -63,7 +63,7 @@ impl TypeGen for OutType {
builder.prop(key, out_type);
}
Property::Scalar(prop) => {
builder.prop(key, remove_injection(prop.wrapper_type_id)?);
builder.prop(key, remove_injections_recursive(prop.wrapper_type_id)?);
}
Property::Unmanaged(type_id) => {
// just forward the original type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
source: typegraph/core/src/runtimes/prisma/type_generation/mod.rs
expression: tp.print(out)
---
root: struct #49
├─ [_avg]: struct '_Post_NumberAgg_avg' #43
│ └─ [id]: optional #42
│ └─ item: float #41
├─ [_count]: struct '_Post_AggrCount' #40
│ ├─ [_all]: optional #39
│ │ └─ item: integer #38
│ ├─ [author]: optional #39
│ │ └─ item: integer #38
│ ├─ [id]: optional #39
│ │ └─ item: integer #38
│ └─ [title]: optional #39
│ └─ item: integer #38
├─ [_max]: struct '_Post_NumberAgg' #48
│ └─ [id]: optional #47
│ └─ item: integer #46
├─ [_min]: struct '_Post_NumberAgg' #48
│ └─ [id]: optional #47
│ └─ item: integer #46
└─ [_sum]: struct '_Post_NumberAgg' #48
└─ [id]: optional #47
└─ item: integer #46
root: struct #51
├─ [_avg]: struct '_Post_NumberAgg_avg' #45
│ └─ [id]: optional #44
│ └─ item: float #43
├─ [_count]: struct '_Post_AggrCount' #42
│ ├─ [_all]: optional #41
│ │ └─ item: integer #40
│ ├─ [author]: optional #41
│ │ └─ item: integer #40
│ ├─ [id]: optional #41
│ │ └─ item: integer #40
│ └─ [title]: optional #41
│ └─ item: integer #40
├─ [_max]: struct '_Post_NumberAgg' #50
│ └─ [id]: optional #49
│ └─ item: integer #48
├─ [_min]: struct '_Post_NumberAgg' #50
│ └─ [id]: optional #49
│ └─ item: integer #48
└─ [_sum]: struct '_Post_NumberAgg' #50
└─ [id]: optional #49
└─ item: integer #48

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

Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
source: typegraph/core/src/runtimes/prisma/type_generation/mod.rs
expression: tp.print(out)
---
root: struct #37
├─ [_avg]: struct '_User_NumberAgg_avg' #31
│ └─ [id]: optional #30
│ └─ item: float #29
├─ [_count]: struct '_User_AggrCount' #28
│ ├─ [_all]: optional #27
│ │ └─ item: integer #26
│ ├─ [id]: optional #27
│ │ └─ item: integer #26
│ ├─ [name]: optional #27
│ │ └─ item: integer #26
│ └─ [posts]: optional #27
│ └─ item: integer #26
├─ [_max]: struct '_User_NumberAgg' #36
│ └─ [id]: optional #35
│ └─ item: integer #34
├─ [_min]: struct '_User_NumberAgg' #36
│ └─ [id]: optional #35
│ └─ item: integer #34
└─ [_sum]: struct '_User_NumberAgg' #36
└─ [id]: optional #35
└─ item: integer #34
root: struct #39
├─ [_avg]: struct '_User_NumberAgg_avg' #33
│ └─ [id]: optional #32
│ └─ item: float #31
├─ [_count]: struct '_User_AggrCount' #30
│ ├─ [_all]: optional #29
│ │ └─ item: integer #28
│ ├─ [id]: optional #29
│ │ └─ item: integer #28
│ ├─ [name]: optional #29
│ │ └─ item: integer #28
│ └─ [posts]: optional #29
│ └─ item: integer #28
├─ [_max]: struct '_User_NumberAgg' #38
│ └─ [id]: optional #37
│ └─ item: integer #36
├─ [_min]: struct '_User_NumberAgg' #38
│ └─ [id]: optional #37
│ └─ item: integer #36
└─ [_sum]: struct '_User_NumberAgg' #38
└─ [id]: optional #37
└─ item: integer #36

Loading

0 comments on commit a13ab9b

Please sign in to comment.