quantified-uncertainty / metaforecast

Fetch forecasts from prediction markets/forecasting platforms to make them searchable. Integrate these forecasts into other services.
https://metaforecast.org/
MIT License
60 stars 6 forks source link

[Umbrella] GraphQL #32

Closed berekuk closed 2 years ago

berekuk commented 2 years ago

Continuing from #21, here's the umbrella issue for adopting GraphQL.

All this is going to take me ~10-15 hours, I think (unless I pick TypeGraphQL, then maybe more since I'm not familiar with it).

This issue doesn't require adopting Prisma, but I might do them both in parallel, not sure yet.

(If any of these subtasks will become large enough then I'll extract them into separate issues and link from here, hence "umbrella".)

NunoSempere commented 2 years ago

Nice, I'm ok defering to you on all of these.

berekuk commented 2 years ago

Turns out that nexus/prisma integration is still a mess. Like, "we tried to rewrite everything from scratch for a year but got stuck/distracted and are hiring a contractor to help" kind of mess.

Of course we don't really need an integration between Prisma and GraphQL framework, it's possible to write all GraphQL types and resolvers by hand. Integration with ORM is for "hey, turn these DB types into GraphQL types magically with a few lines of code" sugar. But it's still handy and scales better.

There's a spectrum of raw code <--> magic which goes like:

  1. Do everything by hand with graphql.js
  2. Use Nexus or other code-first GraphQL framework
  3. Use a framework with Prisma integration
  4. Put PostGraphile / Hasura in front of your DB

On this list, (2) or (3) are nice places to be, and (3) is preferrable. (1) is too much work, and (4) is too much magic, especially when we plan to refactor our DB schema heavily in the future since we just migrated from Mongo and everything is denormalized.

So, I'm evaluating other options. Pothos (mentioned in nexus-prisma thread linked above) seems good; it's basically a Nexus clone with a highly involved author/maintainer and a working prisma integration.

There are some risks of it being less popular (557 stars vs 2.9k stars), e.g. there's a risk of a single author moving on to other stuff and leaving the project to die, but this risk is always there for non-huge opensource projects, so I think that's acceptable if I don't encounter any other significant issues with the lib on initial implementation.