Skip to content

objectType: types all underlying fields, how to make type scoped to those being exposed? #1106

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

You must be logged in to vote

The relationship between typescript types and GraphQL types is important to understand, and isn't intuitive when you are only looking at basic examples.

A good way to think about it is that the typescript types represent your data, and your GraphQL types represent your desired output, and Pothos helps ensure that the way this data is mapped is type-safe. The typescript types do not in any way need to reflect the shape of the GraphQL API.

When you define an objectRef

const User = builder.objectRef<{ id: string, firstName: string, lastName: string }>('User')

you are declaring the data that will be used throughout your schema to represent a User. Any field that returns a User will need to re…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hayes
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