Giter VIP home page Giter VIP logo

Comments (4)

kristian240 avatar kristian240 commented on August 27, 2024

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.

DarkoKukovec avatar DarkoKukovec commented on August 27, 2024

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.

kristian240 avatar kristian240 commented on August 27, 2024

Thanks a lot, @DarkoKukovec :D Would this be considered a breaking change if we are throwing errors?

from datx.

DarkoKukovec avatar DarkoKukovec commented on August 27, 2024

Yeah, I guess so... 🤔
#1179 is also still pending because it is a breaking change

from datx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.