Comments (4)
The issue with this error is that createPost
method is using client.request
. The return type of client.request
is a Response which has either to one or to many relationship. With @datx/swr
we have created 2 new responses - SingleResponse
and CollectionResponse
. To use them, change the client.request
to client.requestSingle
or client.requestCollection
and the type will be correct.
I tried to override the request
method to enhance the DX with this PR but there are other issues that occurred and that are not that easy to solve quickly since a lot of internals are using client.request
and we are doing castings on another level.
Next idea is that to create a eslint
rule to solve throw an error when developer is using client.request
in a project that has @datx/swr
installed, what do you think about that?
One other solution is to check if a client.request
has been called with fetchOptions: { Response: CollectionResponse/SingleResponse }
which will indicate that this is an okay call to make and throw an error if called without - but that does not seem right and this is also causing us to ship more code just to fix the typing issues.
@isBatak @DarkoKukovec @doroz0 what you say on all of this?
from datx.
I didn't notice many places where we're using the request method internally. I changed this behavior and updated a test that failed, and everything seems to be working fine?
94978ed
from datx.
Thanks a lot, @DarkoKukovec :D Would this be considered a breaking change if we are throwing errors?
from datx.
Yeah, I guess so... 🤔
#1179 is also still pending because it is a breaking change
from datx.
Related Issues (20)
- Map option not working properly with relationship. HOT 4
- Map option not working properly in combination with parse HOT 2
- Ability to send empty array or no relations on model.save() HOT 6
- Possible bug with generating post request HOT 3
- Cannot access 'Order' before initialization HOT 2
- [datx-jsonapi] - Support for node 18 fetch
- Search in documentation does not work properly HOT 2
- No export for setRefId
- [Proposal] - introduce new @Field decorator for jsonapi package instead of @Attribute
- Query parameters doubled
- mutate from useDatxInfinite doesn't work in useMutation HOT 1
- Wrong return type on useDatxInfinite
- Datx - required trailing slash in the current state HOT 9
- Error: [MobX] Cannot apply `@action` to `t.prototype.removeOne` HOT 4
- Object is empty inside client after upgrade to v3 HOT 13
- Handle instances of DatX models beeing passed to "getRawData" function.
- Handle response content type
- Project setup issues due to a different global lerna version
- Make datx work with native fetch on node 20 / drop use of `isomorphic-fetch`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datx.