You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just bumped into a types issue with includes for requests - typescript seems to be wanting these include fields to be camelCased like schoolClasses and teacherSubscriptions, but my API expects them as dasherized.
Reading the JSONAPI spec https://jsonapi.org/format/#fetching-includes I can see that it seems to use camelCase for its examples, so it might very well be that my API is not to spec in this regard - though in my interpretation of the spec is that it does allow dasherized relationship paths. But difficult to know for sure
Regardless, is there a way I can handle this other than suppressing the type errors on all my includes calls?
The text was updated successfully, but these errors were encountered:
the JSON:API rule is that includes have to be valid relationship paths. This gets somewhat weird when the api give you dasherized member names, which are exceedingly difficult to use in javascript, and thus on your model (or in your schema) you utilize camelCase member names instead and transform the response.
We follow the JSON:API rule with the type helper with the expectation that any includes that disobey this rule require a ts-expect-error. That your API's format is dasherized member names while your App's format is camelCase member names is why this turns into friction, because the rule is evaluating the App's version.
Workarounds include:
write a query util that doesn't attempt to type-check the relationship paths listed in includes
use dasherized member names in your code (ick)
update your API to use camelCase member names so that it is more JS friendly
Just bumped into a types issue with includes for requests - typescript seems to be wanting these include fields to be camelCased like
schoolClasses
andteacherSubscriptions
, but my API expects them as dasherized.Reading the JSONAPI spec https://jsonapi.org/format/#fetching-includes I can see that it seems to use camelCase for its examples, so it might very well be that my API is not to spec in this regard - though in my interpretation of the spec is that it does allow dasherized relationship paths. But difficult to know for sure
Regardless, is there a way I can handle this other than suppressing the type errors on all my includes calls?
The text was updated successfully, but these errors were encountered: