panter / ra-data-prisma

Packages to connect react-admin with prisma version 2
MIT License
84 stars 28 forks source link

TypeError: graphQLDataProvider is not a function #103

Closed m4tty-d closed 2 years ago

m4tty-d commented 2 years ago

I'm trying to use the latest version of @ra-data-prisma/dataprovider with a typegraphql backend. (crud generated from a prisma schema)

My component looks like this:

import React from "react"
import { Admin, Resource, ListGuesser } from "react-admin"
import { useDataProvider } from "@ra-data-prisma/dataprovider"

const ReactAdmin = () => {
  const dataProvider = useDataProvider({
    clientOptions: { uri: "/api/graphql" },
    queryDialect: "typegraphql",
  })

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

  return (
    <Admin dataProvider={dataProvider}>
      <Resource name="Contractor" list={ListGuesser} />
    </Admin>
  )
}

export default ReactAdmin

When I try to open it in the browser, I'm getting the following error in the console:

TypeError: graphQLDataProvider is not a function
    at eval (buildDataProvider.js?6d27:62)
    at Proxy.eval (convertLegacyDataProvider.js?0029:38)
    at performPessimisticQuery (performPessimisticQuery.js?924a:37)
    at doQuery (doQuery.js?0197:59)
    at Proxy.eval (useDataProvider.js?e59e:188)
    at eval (useQueryWithStore.js?897f:196)
    at new Promise (<anonymous>)
    at eval (useQueryWithStore.js?897f:195)
    at commitHookEffectListMount (react-dom.development.js?61bb:22857)
    at commitPassiveMountOnFiber (react-dom.development.js?61bb:24569)
    at commitPassiveMountEffects_complete (react-dom.development.js?61bb:24533)
    at commitPassiveMountEffects_begin (react-dom.development.js?61bb:24520)
    at commitPassiveMountEffects (react-dom.development.js?61bb:24508)
    at flushPassiveEffectsImpl (react-dom.development.js?61bb:26597)
    at flushPassiveEffects (react-dom.development.js?61bb:26550)
    at eval (react-dom.development.js?61bb:26360)
    at workLoop (scheduler.development.js?1911:256)
    at flushWork (scheduler.development.js?1911:229)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js?1911:523)

I get the same error with and without TS in a brand new CRA app.

I also tried to roll back to the previous version with no luck. :(

Do you guys have any idea what could be the problem?

knapeto commented 2 years ago

Hey! I had the same problem today so I little bit dive into the problem.. I think the main problem is in mix of ra-core versions

Let me know!

makivlach commented 2 years ago

I am also experiencing this issue. Will try to dig into the problem.

kmdavis commented 2 years ago

downgrade ra-data-graphql to v3.11; immediately after that version, there was a complete refactor https://github.com/marmelab/react-admin/commit/59742f5297a3c28af8c0882fad53c01bd4bab511

chrisschaub commented 2 years ago

I am getting the same issue with v4 typegraphql-prisma and ra-data-prisma.

macrozone commented 2 years ago

hey guys, can you all provide which versions you use of react-admin, ra-core and ra-data-prisma

@chrisschaub notice, the error in this issue is related only to the dataprovider, means the frontendpart and therefore has nothing to do with typegraph-prisma

we maybe should no longer rely on ra-data-graphql 🤔

macrozone commented 2 years ago

downgrade ra-data-graphql to v3.11; immediately after that version, there was a complete refactor marmelab/react-admin@59742f5

seems they did not mark it it properly as a breaking change. We can therefore lock the the version or use the new version

macrozone commented 2 years ago

should be fixed now in newest version (stable v6.9.1 or beta v7.0.0-beta.2)