When I add rules to a relation field such as messages, sometimes I may be want to get the messages NOT_READ or READ in one query. Just like this:
query {
me {
id
messagesNotRead: messages(where: {status: NOT_READ}, orderBy: createdAt_DESC) {
id
status
}
messages(where: {status: READ}, orderBy: createdAt_DESC) {
id
status
}
}
}
But after use this middleware, add some rules(like isAuthenticated) to the messages field of type User, the result of the query above is not worked correctly. The renamed field messagesNotRead
cannot work through the validation of the messages field.
The value of messagesNotRead field is just the same of messages above:
{
"data": {
"me": {
"id": "cjn105vxk00110759vg8eq8gz",
"messagesNotRead": [
{
"id": "cjoy6mxbm011k0759uaito9hs",
"status": "READ"
},
{
"id": "cjoy3qcsj010807595jbtqt35",
"status": "READ"
},
],
"messages": [
{
"id": "cjoy6mxbm011k0759uaito9hs",
"status": "READ"
},
{
"id": "cjoy3qcsj010807595jbtqt35",
"status": "READ"
},
]
}
}
}
when just rename the messages without an additional messages field锛宼he renamed field just return null, not []:
query {
me {
id
messagesNotRead: messages(where: {status: NOT_READ}, orderBy: createdAt_DESC) {
id
status
}
}
}
{
"data": {
"me": {
"id": "cjn105vxk00110759vg8eq8gz",
"messagesNotRead": null
}
}
}
md5-0867ce19311f444d02594b444a676736
query {
me {
id
messages(where: {status: NOT_READ}, orderBy: createdAt_DESC) {
id
status
}
}
}
md5-442a2276f0e7cfb5911d8f20765f2def
{
"data": {
"me": {
"id": "cjn105vxk00110759vg8eq8gz",
"messages": []
}
}
}
Hey @baby1990 馃憢,
That's an interesting question! Could you provide a reproduction repository or CodeSandbox? This way I can curb the issue a lot more quickly. 馃檪
Hey @baby1990 馃憢,
That's an interesting question! Could you provide a reproduction repository or CodeSandbox? This way I can curb the issue a lot more quickly. 馃檪
I try to use graphql-yoga and graphql-shield to perform a simple demo for this situation. But the demo works correctly.
The problems above accurs when I use graphql-prisma / graphql-yoga / graphql-shield to perform a backend service. I wonder it maybe a problem of graphql-prisma.
@baby1990, let me know if you find any further information. Maybe this could be connected to field alias, could you try that as well?
Regardless, I think it would be super useful if we could have a common ground with a reproduction example. Let me know if you could compose that. 馃檪
@baby1990, let me know if you find any further information. Maybe this could be connected to field alias, could you try that as well?
Regardless, I think it would be super useful if we could have a common ground with a reproduction example. Let me know if you could compose that. 馃檪
Ok, I work it out, https://github.com/baby1990/test-graphql-shield
The prisma version is 1.17, and the problems accurs...
Maybe it works well on newer version, I doesn't know about it.
@baby1990, let me know if you find any further information. Maybe this could be connected to field alias, could you try that as well?
Regardless, I think it would be super useful if we could have a common ground with a reproduction example. Let me know if you could compose that. 馃檪
I try to update my prisma service to 1.24(latest version)锛宎nd the problems not resolved.
@baby1990, let me know if you find any further information. Maybe this could be connected to field alias, could you try that as well?
Regardless, I think it would be super useful if we could have a common ground with a reproduction example. Let me know if you could compose that. 馃檪
I checked the response data of prisma-service, seems no problem. Maybe something went wrong with the resolve logic of graphql-yoga(work with prisma and shield)
@baby1990, let me know if you find any further information. Maybe this could be connected to field alias, could you try that as well?
Regardless, I think it would be super useful if we could have a common ground with a reproduction example. Let me know if you could compose that. 馃檪
Actually, I tried to use the custom directives to do the permission instead of graphql-shield. But the problems not resolved. So I don't think there is something wrong with graphql-shield.
https://github.com/prisma/prisma/issues/3881#issuecomment-456842794
@maticzav this is totally unrelated to graphql-shield I think you can close this here 馃檪
Due to @pantharshit00's investigation, I'll close the issue. Feel free to reopen it if you feel this is still a relevant topic.
Hey :wave:,
We saw you use our package. To keep our code as accessible as possible, we decided to open source it and are now helping others with their questions.
In a pursuit to continue our work, help us by donating to our collective! :heart: