question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook: if mock data structure does not match QUERY exactly, wrong error is thrown

See original GitHub issue

Update: https://github.com/redwoodjs/redwood/issues/1380#issuecomment-990482233

If you have a QUERY in a cell like:

export const QUERY = gql`
  query BlogPostsQuery {
    posts {
      id
      title
      body
      createdAt
    }
  }
`

But in the associated story mock, the return data is missing one or more fields:

export const standard = (/* vars, { ctx, req } */) => ({
  posts: [
    {
      id: 1,
      title: 'First post',
      body: 'Neutra tacos hot chicken prism raw denim...',
    },
  ]
})

(createdAt is missing) you’ll get a weird error in the story that data is missing completely:

image

This literal error is coming from withCell (which is thrown when data is indeed null) but it appears that something we’re doing somewhere is swallowing the real error and we’re left with this.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
peterpcommented, Mar 24, 2021

I think we should add it to the queue - it would make dev/ testing/ storybook so much nicer.

1reaction
jtoarcommented, Dec 10, 2021

While I don’t see this issue happening anymore, the idea of wrapping a Cell in a dev-friendlier error boundary is still worthwhile, so I’ll leave this issue open but remove it’s bug/v1 status.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL schema basics - Apollo GraphQL Docs
This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which...
Read more >
Frequently Asked Questions - Storybook - JS.ORG
Why are my mocked GraphQL queries failing with Storybook's MSW addon? Can I use other GraphQL providers with Storybook's MSW addon? Can I...
Read more >
Match query | Elasticsearch Guide [8.5] | Elastic
Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching. The match query is...
Read more >
Testing | RedwoodJS Docs
Try running that code again and you should see "fail: no error thrown" in the ... went wrong (the expected and actual values...
Read more >
sqlmock: expectations do not match (being exactly the same ...
Why you mock SQL queries? It's better to write a real integration test to check queries with a real database. Mocking is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found