NOTE: This problem may be with nexus-prisma and not prisma-client-lib. I'm sorry if that's the case.
Describe the bug
There's a bug with prisma-client-lib where if you have chained embedded types, it's not possible to query the embedded fields on 2nd or 3rd level.
To Reproduce
I have these embedded types
type StateMachine {
id: ID! @id
states: [StateMachineState]
...
}
type StateMachineState @embedded {
transitions: [StateMachineStateTransition]
...
}
type StateMachineStateTransition @embedded{
action: String!
pre: [StateMachineStatesTransitionHook] @relation(name: "PreHook")
post: [StateMachineStatesTransitionHook] @relation(name: "PostHook")
...
}
type StateMachineStatesTransitionHook @embedded{
hook: String
...
}
In the database the result should look something like this:
{
"_id" : ObjectId("5c6fff231ed7970008c949f4"),
"states" : [
{
"transitions" : [
{
"action": "some action"
"pre" : [
{
"hook": "do something"
}
],
"post" : [],
}
]
}
],
}
When I make a create mutation, the document is created correctly in the database. But I can't query for transitions or pre, because I get an error.
If I do:
createStateMachine(
data: {
states: {
create: {
transitions: { create: { action: "someaction" } }
}
}
}
) {
id
states {transitions { pre(where: {}) {action}}}
}
The result is:
{
"data": {
"createStateMachine": {
"id": "5c6fff231ed7970008c949f4",
"states": [
{
"transitions": null
}
]
}
},
"errors": [
{
"message": "Unknown prisma-client function for field StateMachineState.transitions",
"locations": [
{
"line": 5,
"column": 7
}
],
"path": [
"createStateMachine",
"states",
0,
"transitions"
]
}
]
}
Expected behavior
I expect to be able to query embedded fields on many levels, and no only the first one
Versions (please complete the following information):
MongoDB1.26.6prisma CLI: prisma/1.26.6 (linux-x64) node-v10.15.1Linux Mint 19 Cinnamonprisma-client, nexus-prisma,Additional context
I'm using nexus-prisma and the problem may be with their implementation on the client, but I don't know if that's the case. For now what I can gather is that the function to get the second level of embedded (transitions) is expected to be on root level of that prisma-client as you can see on this line: https://github.com/prisma/nexus-prisma/blob/master/packages/nexus-prisma/src/resolver.ts#L98
If the bug is indeed on the nexus-prisma implementation, I'm sorry and I can post this issue there.
Thanks!
I have a similar Issue.
With this types:
type InputTemplate {
id: ID! @id
name: String!
inputData: InputTemplateInputData
}
type InputTemplateInputData @embedded{
type: InputTemplateInputDataType
options: [String]
unit: String
}
enum InputTemplateInputDataType {
Value,
Multiple
}
If I ask for the inputData{type} to be returned I get :

if I don't I get no error.
I'm also using * prisma-client, nexus-prisma.
It must be something with the client because when I do the same query directly on the prisma server playground all works fine.
Thanks!
Same problem here with Prisma+Nexus-Prisma+MySQL
Hey there,
Thanks for reporting! That's indeed a bug on nexus-prisma side. That's because embedded types are automatically fetched just like scalars values, unlike regular types.
I'll tell you once that's fixed 馃檹
This should now be fixed under [email protected].
You can see the release notes here: https://github.com/prisma/nexus-prisma/releases/tag/v0.3.4
Feel free to re-open if this is still occuring
I think I'm experiencing the same issue with [email protected].

Any workaround for this? I am also unable to call aggregate. I'm on [email protected]
Most helpful comment
I think I'm experiencing the same issue with
[email protected].