Skip to content

How to reduce redundancy when declaring custom object types? #724

Answered by hayes
ChristianIvicevic asked this question in Q&A
Discussion options

You must be logged in to vote

The short answer is to use the simple objects plugin: https://pothos-graphql.dev/docs/plugins/simple-objects

The longer answer is that by default Pothos does not assume your data and your API have the same shape, which means that in Pothos you define the shape of your data (using a typescript type, class, or some other (plugin specific) method), then you define fields and define how those fields are resolved from that data. It may feel a little repetitive at first, especially in a new project, but this pattern pays off as you evolve apps over time and things start to grow more complex.

The simple objects plugin gives you a way to quickly define objects without specifying types of resolver…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ChristianIvicevic
Comment options

Answer selected by ChristianIvicevic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants