Getting error when using ra-graphql-simple with react-admin

Viewed 2048

My react-admin imp seems to be able to connect to a strapi api I've spun up and configured with the graphql plugin, but I get an error saying my client essentially doesn't know one of my strapi collections exists:

Unknown resource 'products'. Make sure it has been declared on your server side schema. Known resources are

That's the full message that appears in a flash. No actual list of resources.

My App.js is the following:

class App extends Component {
  constructor() {
    super();
    this.state = { dataProvider: null };
  }
  componentDidMount() {
    buildGraphQLProvider({
      clientOptions: {
        uri: 'http://localhost:1337/graphql',
      },
    }).then(dataProvider => {
      this.setState({ dataProvider })
    }).catch((err) => {
      console.error(err);
    });
  }
  render() {
    const { dataProvider } = this.state;
    if (!dataProvider) {
      return <div>Loading</div>;
    }
    return (
      <Admin
        authProvider={authProvider}
        dataProvider={dataProvider}
        i18nProvider={i18nProvider}
        title="GridPlus"
        locale="en"
        customRoutes={[
            <Route
                exact
                path="/custom"
                component={CustomRouteNoLayout}
                noLayout
            />,
            <Route exact path="/custom2" component={CustomRouteLayout} />,
        ]}>
        <Resource name="products" {...products} />
    </Admin>
    );
  }
}

export default App;

Any ideas why admin-client isn't able to see my products collection?

Thanks.

1 Answers

ra-data-graphql-simple send an introspection query to your graphql backend when it starts, gathering all possible resources matching the gql dialect it understands.

A dialect is a way to name the queries and mutations for each resource. For a resource to be detected, your schema must have the expected shape defined in the documentation.

Most of the time, you'll have to implement your own dialect using ra-data-graphql.

Related