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

cacheDataProviderProxy not called with ra-data-graphql-simple #6438

Closed
RWOverdijk opened this issue Jul 15, 2021 · 4 comments
Closed

cacheDataProviderProxy not called with ra-data-graphql-simple #6438

RWOverdijk opened this issue Jul 15, 2021 · 4 comments

Comments

@RWOverdijk
Copy link
Contributor

RWOverdijk commented Jul 15, 2021

I wasn't sure if I should put this here or on the ra-data-graphql-simple repo. I'm not even sure if this is an actual bug or just me doing something wrong.

What you were expecting:

I was expecting cacheDataProviderProxy's get() to be called when used with graphql. I notice that every Edit performs a get and I want to use the cacheDataProviderProxy to prevent that.

What happened instead:

I've added several logs and none of them are being called. I verified my logs are there in the browser, and they are.

Screenshot collapsed, click to expand.

image

Steps to reproduce:

Using the default code in the ra-data-graphql-simple readme with the addition of the cacheDataProviderProxy.

Code collapsed, click to expand.
import * as React from 'react';
import { Component } from 'react';
import buildGraphQLProvider from 'ra-data-graphql-simple';
import { Admin, cacheDataProviderProxy } from 'react-admin';

class App extends Component {
  constructor(props) {
    super(props);

    this.state = { dataProvider: null };
  }

  componentDidMount() {
    // 👇 This is where I added the `cacheDataProviderProxy()` 👇 
    buildGraphQLProvider({ clientOptions: { uri: 'http://localhost:4000/graphql' }})
        .then(dataProvider => this.setState({ dataProvider: cacheDataProviderProxy(dataProvider) }));
  }

  render() {
    const { dataProvider } = this.state;

    if (!dataProvider) {
      return <div>Loading</div>;
    }

    return (
        <Admin dataProvider={dataProvider}>
        </Admin>
    );
  }
}

export default App;

Environment

  • React-admin version: 3.16.6 (waiting for material-ui fix)
  • Last version that did not exhibit the issue (if applicable): N/A
  • React version: 17.0.2
  • Browser: Chrome
  • Stack trace (in case of a JS error): N/A
@djhi djhi closed this as completed Jul 22, 2021
@djhi djhi reopened this Jul 22, 2021
@djhi
Copy link
Collaborator

djhi commented Jul 22, 2021

Sorry I closed that too fast. This is because the graphql dataproviders have not been updated to the new dataProvider format. They still return a single function instead of an object. Flagging this as an enhancement

@RWOverdijk
Copy link
Contributor Author

Thanks.

If nobody picks this up I'll see if I can tackle this next time I work on this project. How hard can it be, right. Sounds like the function is replaced by an object literal where the previous action argument is now the key. Is that correct?

@djhi
Copy link
Collaborator

djhi commented Jul 22, 2021

Exactly!

@djhi
Copy link
Collaborator

djhi commented Oct 4, 2021

Fixed by #6628

@djhi djhi closed this as completed Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants