Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing a non existand data from the mockStore complains about the wrong thing #2320

Open
nemonemi opened this issue Jun 16, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@nemonemi
Copy link
Contributor

Describe the bug

Accessing a resource from the mockStore that doesn't exist doesn't handle the situation well. It complains about the DateTime not being defined, and not that the resource access attempt is invalid.

image

This is how I handle the resource detail:

  resourceDetail: (_, { id }, { mockStore }) => {
    // here I'd like to check if the resource exists and then return a handled error
    return mockStore.get('ResourceDetail', id);
  },

I assume I should protect the endpoint, but how can this be done with the mockStore?

@ardatan ardatan added the bug Something isn't working label Jun 16, 2021
@ardatan
Copy link
Owner

ardatan commented Jun 16, 2021

Not sure if it is directly related but could you try with the following alpha version?
@graphql-mesh/transform-mock@0.10.0-alpha-50997b77c.0

@nemonemi
Copy link
Contributor Author

@ardatan, I've tested the error returned when accessing the resource which isn't there, but there was no change in the behavior.

@ardatan
Copy link
Owner

ardatan commented Jun 17, 2021

Could you help me to reproduce it or creating a failing test would be even better?

@nemonemi
Copy link
Contributor Author

nemonemi commented Jun 17, 2021

@ardatan
Okay, here it is: https://github.com/nemonemi/graphql_ensemble/tree/graphql-error-handling

  1. install dependencies
  2. run yarn startGateway
  3. get a valid ID from the query Authors
  4. run query Author with that ID
  5. observe that it works
  6. run the same query Author with a wrong ID
  7. observe the error "No mock defined for type \"DateTime\""

I have also added another issue of a similar type when trying to handle errors with union types:
8. run the query AuthorPerhaps
9. observe the error "Cannot read property 'name' of undefined"

Where does this error come from?

@nemonemi
Copy link
Contributor Author

@ardatan, have you made any progress with this issue?

@nemonemi
Copy link
Contributor Author

@Urigo ,
How about this issue?

@nemonemi
Copy link
Contributor Author

Guys... it's been more than 2 months since I've provided the reproduction. Could you please look into it?

@tvvignesh
Copy link
Contributor

@ardatan You can assign this issue to me. I will have a look at it this week.

@ardatan ardatan self-assigned this Jan 2, 2022
@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants