Problems work with the renamed field
See original GitHub issueWhen 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,the 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
}
}
}
The expected result should like this:
query {
me {
id
messages(where: {status: NOT_READ}, orderBy: createdAt_DESC) {
id
status
}
}
}
{
"data": {
"me": {
"id": "cjn105vxk00110759vg8eq8gz",
"messages": []
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Problems work with the renamed field when using graphql ...
When I use graphql-prisma / graphql-yoga / graphql-shield together to perform a backend service, the renamed field not work.
Read more >Problem renaming a field in a query - Microsoft Community
My user wants me to rename some fields in a query, but it's not working. If I put in the Field column either...
Read more >Unable to rename work item field - Visual Studio Feedback
Resolved the issue. There was data in the field for several work items. Once the data was cleared I was able to delete...
Read more >Problems Renaming Fields with Make Feature Layer
If you are on 10.2 +, consider using the Alter Field GP tool instead if you can't get Make Feature Layer working. ·...
Read more >Rename field problem - Logstash - Discuss the Elastic Stack
I suspect that you are storing field names that are getting extracted including quotation characters in the field name. You could remove them ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/prisma/prisma/issues/3881#issuecomment-456842794
@maticzav this is totally unrelated to graphql-shield I think you can close this here 🙂
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.