debate-cards
debate-cards copied to clipboard
Public GraphQL API
Placeholder. Possibly auto-generated from Prisma schema auto-generate from Prisma schema. Should it be a module?
Not sure if typegraphql-prisma is really the best for this use case
The only queries we really need directly from the database are getting things by id's and basic relational queries, we'd only end up using like 1% of the queries it generates.
The interface is also probably over complicated, if you just want to get a card by an id you have to include the whole {where: {id: 123}}
in the argument. We would also have to lock down some of the more complicated arguments that could be passed, and I'm not sure if there is a good way to do that.
The queries it generates also aren't very optimized for what we are doing, for example if you just want the id of the file a card belongs to, it would still load the full text, markup etc. of the card from the database.
It might still be useful for generating the models for the queries, but not sure if its really worth it at that point. You can get some type safety by doing
import 'reflect-metadata';
import { Field, ID, ObjectType } from 'type-graphql';
import { Evidence as EvidenceSchema } from '@prisma/client';
@ObjectType()
export class Evidence implements Partial<EvidenceSchema> {
@Field((type) => ID)
gid: string;
@Field()
tag: string;
// ...
}