-
Hi, I'm encountering an issue with ID scalars that’s adding unnecessary complexity to my resolvers. In my database, primary keys are mostly integers with a few strings. However, in almost every resolver that interacts with a table using an integer-based primary key, I have to manually convert the ID string into an integer before performing any operations. This results in repetitive and cluttered code across hundreds of resolvers. I'm wondering if there's a way to extend the argument builder in Pothos GraphQL to streamline this process. Specifically, I'd like to introduce a property like Here’s a current example of what I’m doing:
What I'd like to achieve instead:
This would significantly reduce clutter and make the code more concise. Is there any way to accomplish this or something similar in Pothos? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can build a plugin to add an intID method to the schema builder like this: |
Beta Was this translation helpful? Give feedback.
You can build a plugin to add an intID method to the schema builder like this:
https://stackblitz.com/edit/typescript-dftsbi?file=index.ts