Cannot install graphql-client (missing from package set)

Hey everyone,

I’m trying to get graphql-client to work but I cannot get spago (neither 0.21.0 nor 0.93.39) to install it:

spago install graphql-client
[error] The following packages do not exist in your package set:
[error]   - graphql-client

or for spago@next>

 Reading Spago workspace configuration...

✓ Selecting package to build: gql


✘ The following packages do not exist in your package set:
  - graphql-client

My versions are:

node 20.17
purs 0.15.15
spago 0.21.0 || 0.93.39

I’m on Windows 10 using PowerShell.

Interestingly enough:

spago registry search graphql-client
Searching for "graphql-client" in the Registry package names...
Use `spago registry info $package` to get more details on a package.
+----------------+---------+--------------------------+
| NAME           | VERSION | PUBLISHED TIME           |
+----------------+---------+--------------------------+
| graphql-client | 9.3.2   | 2022-12-30T15:22:20.000Z |
+----------------+---------+--------------------------+

spago info returns a bunch of versions as expected.

I can install other packages (e.g. halogen) just fine.

Any Idea?

The package is not in the package set that you’re using (which you can query with spago ls packages btw), and it was likely dropped from the set because it is not compatible with the latest compiler releases or some other package it depends on.

In fact you can see from the registry search that the last release was in 2022, which is quite a few compiler releases ago.

You can add any package from the registry to your build by adding it to the extraPackages, see the docs here.
It’s highly likely that the package will fail to build though, in which case you could fork it and patch it to work with the latest compiler/packages.

What a bummer! There are commits in the github repo as late as 2 months ago, but the repo uses the old spago.

Thank you for your help showing me how to get extra packages to work. Your prediction was correct: The package won’t work out of the box and since it depends on generated code from another tool I will probably have a hard time matching the two versionwise.

Seems like I cannot have both Purescript and GraphQL right now :frowning:

It doesn’t matter if the repo uses the old spago, you can still import it using the git syntax documented in the link I posted in the previous comment. The only thing to pay attention to is that you’ll need to add a dependencies key as well, listing the dependencies from the spago.dhall upstream (this is the step that you could skip if the upstream was using a spago.yaml).

Commits from two months ago are a good sign and make it likely that the package would be compatible with the latest package set. Give it a try!

Following your instructions I got spago to download the package with no issues but I can’t seem to get any version of the package to work. Either the codegen works but the package itself doesn’t compile or the codegen errors out and i cannot even test the package. There is already an issue on github asking if there is support for the current version of spago coming but there hasn’t been an answer for over a month so I don’t think the package is very active after all.

I don’t know how I’m going to proceed. Maybe I’ll just do the graphQL part in JS and use the FFI.

Thank you for your help! The packageset thing was bugging me a whole lot and I’m happy to have that figured out!

I took a look at the package set in use by graphql-client, and it’s a little old:
https://github.com/OxfordAbstracts/purescript-graphql-client/blob/f9fa0cce758ec12bd7407c578e27a02a7dbd45b4/packages.dhall#L2

That corresponds with this package set (or, in new Spago, package set 20.0.3).
https://github.com/purescript/package-sets/releases/psc-0.15.7-20230408

I’m sure some of these libraries it depends on have had breaking changes in the last year and a half, so you may simply be hitting a compilation error from that. You can always try setting your project to use the same package set as purescript-graphql-client is using as a stopgap solution, as that will guarantee you’re using the same dependencies as them.

1 Like

Thank you guys for your help.

There was one last puzzle piece left after all your advice:

  1. You helped me get extra packages/a working package set to work
  2. I needed to match the npm install purescript-graphql-client package that handles the schema generation needed to match the version used in spago
  3. The library seems to generate invalid code for my schema: It generated queries returning a Node type which was never defined. Those queries are not strongly types and the Node can be any object in my schema. This can be used with inline fragments. I commented out the offending part and now it builds.

I haven’t started building and testing with it because honestly it’s the first time I got the code to build at all so I still don’t know how this library works. Thank you guys for helping me get to this point thought!