New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make id arg required in singular content type graphql request #15877
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #15877 +/- ##
==========================================
+ Coverage 60.68% 66.30% +5.61%
==========================================
Files 1495 1121 -374
Lines 36878 22792 -14086
Branches 7359 4191 -3168
==========================================
- Hits 22380 15112 -7268
+ Misses 12417 6800 -5617
+ Partials 2081 880 -1201
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This change looks good to me, I think you can update this with main and it should be fine to mover forward with this fix |
Hi all, Had some headaches after installing this update because this commit is causing my application to break. I want to query based on SLUG instead of ID an followed this tutorial: In short, this is the code we used
},` Which of course is causing this error: Any idea on how to bypass the "ID is required" issue? It seems like a lot of developers are using that tutorial to query their contentTypes, will keep an eye out for future issues because not everyone is reading updates. Thanks a lot! |
This pull request has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/strapi-v4-search-by-slug-instead-id/13469/54 |
What does it do?
Makes the "id" argument in Graphql queries required for singular content type requests (eg, "restaurant" but not "restaurants" or single types)
Despite changing the schema, I do not believe it should be considered a breaking change because currently the queries are already broken, so this only corrects the type of error that is returned.
Why is it needed?
Before this PR, failing to include an id results in an invalid query that goes all the way to the database layer:
After this PR, we catch the missing ID with the graphql schema:
How to test it?
Test that id argument is now required for singular content request types that previously had only an "id" arg that wasn't required.
It should not be required for single types or multiple request queries