MrHertal / react-admin-amplify

AWS Amplify data provider for react-admin.
MIT License
159 stars 43 forks source link

Cannot read properties of undefined (reading 'nextToken') #60

Closed NicoleHComune closed 2 years ago

NicoleHComune commented 3 years ago

I have a Create view that contains a ReferenceArrayInput and AutocompleteArrayInput, I would like this "dropdown"'s items to be filtered.

In this case the dropdown shows a list of Careers, however I only want Careers that have a flag, called relatedCareer, equal to 1 to show up in dropdown. The query for this is below

<ReferenceArrayInput
 label="Related Careers"
 source="relatedCareers"
 reference="careers"
 filter={{ flaggedAsRelatedCareer: { relatedCareer: 1 } }}
>
 <AutocompleteArrayInput />
</ReferenceArrayInput>
query FlaggedAsRelatedCareer(
      $relatedCareer: Int = 1
      $limit: Int
      $nextToken: String
    ) {
    listCareers(filter: {relatedCareer: {eq: $relatedCareer}}, limit: $limit, nextToken: $nextToken) {
      items {
        id
        name
        relatedCareer
      }
      nextToken
    }
  }

In the Network tab of the console I can see the data being returned by the query is what I'm expecting:

data: 
 listCareers: 
  items: 
   0: {id: "related-career-1-id", name: "Related Career 1", relatedCareer: 1}
  nextToken: null

However I get the following error:

index.js:1 TypeError: Cannot read properties of undefined (reading 'nextToken')
    at DataProvider.<anonymous> (DataProvider.ts:127)
    at step (tslib.es6.js:102)
    at Object.next (tslib.es6.js:83)
    at fulfilled (tslib.es6.js:73)

Is there something I am missing here?

seunghwako commented 2 years ago

Is it update anything?