graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

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

Open nemonemi opened this issue 3 years ago • 8 comments

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?

nemonemi avatar Jun 16 '21 13:06 nemonemi

Not sure if it is directly related but could you try with the following alpha version? @graphql-mesh/[email protected]

ardatan avatar Jun 16 '21 18:06 ardatan

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

nemonemi avatar Jun 17 '21 08:06 nemonemi

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

ardatan avatar Jun 17 '21 08:06 ardatan

@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 avatar Jun 17 '21 10:06 nemonemi

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

nemonemi avatar Jun 29 '21 12:06 nemonemi

@Urigo , How about this issue?

nemonemi avatar Sep 24 '21 14:09 nemonemi

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

nemonemi avatar Nov 14 '21 14:11 nemonemi

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

tvvignesh avatar Jan 02 '22 16:01 tvvignesh