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.

ra-data-graphql-simple ReferenceManyField target Filter

See original GitHub issue

What you were expecting: After making changes to the target parameter, I was finally able to remove another crutch. Thanks so much for this.

But there is one more problem. Here is the request sent in List:

const DistrictFilter = (props) => (
    <Filter {...props}>
        <ReferenceInput source="gasRegion.id" reference="GasRegion" allowEmpty emptyText="ra.message.no">
            <AutocompleteInput optionText="name" />
        </ReferenceInput>
    </Filter>
);

==>

{operationName: "allGasDistricts",…}
operationName: "allGasDistricts"
query: "query allGasDistricts($page: Int, $perPage: Int, $sortField: String, $sortOrder: String, $filter: GasDistrictFilter) {↵  items: allGasDistricts(page: $page, perPage: $perPage, sortField: $sortField, sortOrder: $sortOrder, filter: $filter) {↵    id↵    name↵    description↵    createdAt↵    createdBy {↵      id↵      name↵      email↵      phone↵      __typename↵    }↵    updatedAt↵    deleted↵    gasRegion {↵      id↵      name↵      description↵      __typename↵    }↵    gasMeterPads {↵      id↵      name↵      description↵      __typename↵    }↵    reports {↵      id↵      name↵      description↵      type↵      template↵      __typename↵    }↵    tags {↵      id↵      name↵      description↵      color↵      resource↵      __typename↵    }↵    aisId↵    __typename↵  }↵  total: _allGasDistrictsMeta(page: $page, perPage: $perPage, filter: $filter) {↵    count↵    __typename↵  }↵}↵"
variables: {filter: {gasRegion: {id: "ck7omjmc40000pcurc9zc8usn"}}, page: 0, perPage: 10, sortField: "updatedAt",…}
filter: {gasRegion: {id: "ck7omjmc40000pcurc9zc8usn"}}
gasRegion: {id: "ck7omjmc40000pcurc9zc8usn"}
id: "ck7omjmc40000pcurc9zc8usn"
page: 0
perPage: 10
sortField: "updatedAt"
sortOrder: "DESC"

pay attention to the filter:

filter: {
    gasRegion: {
         id: "ck7omjmc40000pcurc9zc8usn"
     }
}

This is exactly what i expect to see. This is working correctly.

What happened instead: However, if I want to get the same data with:

<ReferenceManyField 
                label="resources.GasRegion.fields.gasDistricts"
                reference="GasDistrict" 
                target="gasRegion.id" 
                sort={{ field: 'updatedAt', order: 'DESC' }}
                pagination={<Pagination />}
                perPage={25} 
            >
                <GasDistrictReferenceDatagrid />
            </ReferenceManyField>

such a request is sent:

{operationName: "allGasDistricts",…}
operationName: "allGasDistricts"
query: "query allGasDistricts($page: Int, $perPage: Int, $sortField: String, $sortOrder: String, $filter: GasDistrictFilter) {↵  items: allGasDistricts(page: $page, perPage: $perPage, sortField: $sortField, sortOrder: $sortOrder, filter: $filter) {↵    id↵    name↵    description↵    createdAt↵    createdBy {↵      id↵      name↵      email↵      phone↵      __typename↵    }↵    updatedAt↵    deleted↵    gasRegion {↵      id↵      name↵      description↵      __typename↵    }↵    gasMeterPads {↵      id↵      name↵      description↵      __typename↵    }↵    reports {↵      id↵      name↵      description↵      type↵      template↵      __typename↵    }↵    tags {↵      id↵      name↵      description↵      color↵      resource↵      __typename↵    }↵    aisId↵    __typename↵  }↵  total: _allGasDistrictsMeta(page: $page, perPage: $perPage, filter: $filter) {↵    count↵    __typename↵  }↵}↵"
variables: {filter: {gasRegion.id: "ck7omjmc40000pcurc9zc8usn"}, page: 0, perPage: 25, sortField: "updatedAt",…}
filter: {gasRegion.id: "ck7omjmc40000pcurc9zc8usn"}
gasRegion.id: "ck7omjmc40000pcurc9zc8usn"
page: 0
perPage: 25
sortField: "updatedAt"
sortOrder: "DESC"

filter: {gasRegion.id: "ck7omjmc40000pcurc9zc8usn"}

This is a mistake.

I expected that in both cases the same filter will be generated.

Environment

  • React-admin version: 3.4.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jschroed91commented, May 28, 2020

Experiencing the same issue - any resolution here?

0reactions
fzaninottocommented, Jul 21, 2022

No news for some time, closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The ReferenceManyField Component - React-admin - Marmelab
This component fetches a list of referenced records by a reverse lookup of the current record.id in the target field of another resource...
Read more >
Is it possible to add user search filters to a ... - Stack Overflow
I did notice the moment the List component is injected, the ReferenceManyField target value is ignored. Your code has a { user: record.id...
Read more >
How To Display The Id Of An Item In A List Resource And A ...
The Datagrid should only see records with the target value filter applied. ... Datagrid within ReferenceManyField showing rows but no data.
Read more >
Is it possible to add user search filters to a ... - Anycodings.com
Answers 2 : of Is it possible to add user search filters to a ReferenceManyField in React Admin v3 ; ReferenceManyField reference="some-reference" target="some- ......
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