jeddeloh / rescript-apollo-client

ReScript bindings for the Apollo Client ecosystem
MIT License
126 stars 18 forks source link

Update ApolloClient__Graphql_Language.res so type documentNode is no longer abstract. #114

Closed JasoonS closed 3 years ago

JasoonS commented 3 years ago

I just started a new project with the latest version of rescript and rescript-apollo client on the backend nodejs. And ran into the following error: image

Making that change solved it for me. But I don't know the nuances of this change at all...

(additional info, I tried this code on bs-platform 9.0.2 also, same thing error)

JasoonS commented 3 years ago

My current fix - add this line as a post install script to my package.json: "postinstall": "sed -i 's/type documentNode/type documentNode = string/g;s/type documentNode = string = string/type documentNode = string/g' node_modules/rescript-apollo-client/src/graphql/language/ApolloClient__Graphql_Language.res",

Which reliably replaces that line of code on a new install...

jeddeloh commented 3 years ago

Could you post your bsconfig? That error usually means that you're missing the template tag configuration like "templateTagReturnType" in your config. For background, the graphql definition is normally just a string, but it's converted to documentNode by running through gql. This made to happen through the configuration. The type error is probably correct.

Are you sure the app is functional after that and you're not just getting the compiler to be happy?

JasoonS commented 3 years ago

Yeah, you are right. It isn't functional.

I'm not sure what the issue is to be honest. If I use the example you have in this repo and don't change much everything works. I get the problem when using newer versions of rescript. So I'll just stick with the older bs-platform for now :)

JasoonS commented 3 years ago

I found the issue!

In general the bsconfig.json file allows trailing commas, but graphqlppx does not!

JasoonS commented 3 years ago

Thank you for your help and patience :)