GithubHelp home page GithubHelp logo

Comments (9)

kentcdodds avatar kentcdodds commented on May 10, 2024 1

Oh! Nice! I didn't realize that API exists. Would you be interested in making a PR for that?

from react-suspense.

kentcdodds avatar kentcdodds commented on May 10, 2024

Hmmm... I thought @cesarcf had addressed this in https://github.com/kentcdodds/react-suspense/pull/37 🤔

from react-suspense.

intrueder avatar intrueder commented on May 10, 2024

I'm not sure it was a complete fix, because there are two places where the promise is being rejected, but only one was changed from Error to String.
Moreover, ErrorFallback component relies on Error object since it outputs error.message and not just error.

Anyway, this is a different issue, and my previous comment is more about checking the result from the API.
Currently the code checks response.errors, but should check response.data.errors:

      if (response.data.errors) {
        return Promise.reject(
          new Error(response.data.errors.map(e => e.message).join('\n')),
        )
      }

from react-suspense.

kentcdodds avatar kentcdodds commented on May 10, 2024

I think I misunderstood the issue @cesarcf was talking about in #37 and that change should be reverted. Doing that now.

from react-suspense.

kentcdodds avatar kentcdodds commented on May 10, 2024

@all-contributors please add @intrueder for bugs

from react-suspense.

allcontributors avatar allcontributors commented on May 10, 2024

@kentcdodds

I've put up a pull request to add @intrueder! 🎉

from react-suspense.

intrueder avatar intrueder commented on May 10, 2024

I just realized, that response.errors is probably there to handle server errors, and if pokemon name is misspelled then error will be handled by else branch, that's why there is no check for response.data.errors
But... what is a server error then? I tried to simulate it by breaking a graphql request (some invalid variable: variables: {namez: name.toLowerCase()}) and the response has no errors field:

image

At the same time GraphiQL console works in a very different way, I can't see data.errors field in the result:

image

from react-suspense.

kentcdodds avatar kentcdodds commented on May 10, 2024

Keep in mind that we don't actually have a real server in this workshop (so it works offline): https://github.com/kentcdodds/react-suspense/blob/c6a440d3b04b5ba6693423b6c8e65f5fd9c8dbaa/src/backend.js#L32

from react-suspense.

intrueder avatar intrueder commented on May 10, 2024

Haha 😄 Totally forgot about this. Thanks!
So, here is the problem:
https://github.com/kentcdodds/react-suspense/blob/c6a440d3b04b5ba6693423b6c8e65f5fd9c8dbaa/src/backend.js#L42

I believe it should be:

        ctx.errors([
          {
            message: `Unsupported pokemon: "${req.variables.name}". Try "${randomName}"`,
          },
        ])

from react-suspense.

Related Issues (19)

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.