Skip to content
Discussion options

You must be logged in to vote

Hello,
Hopefully I understanding your question right: you are asking how to avoid having to resolve an object in the parent, because you want to resolve it at the field level using server preset.

In this case, the recommended way is to use mappers to let Codegen know your intention.

Let's use this :

# src/app/schema.graphql
type Query {
  user: User
}

type User {
  id: ID!
  name: String!
  favouriteBook: Book
}

type Book {
  id: ID!
  title: String!
}

And you may store a "User" this in your database:

{
  id: string;
  name: string;
  favouriteBookId?: string; // we store book records in a different table, and this ID is the foreign key
}

Then, you may use the Database User interface a…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@ZCY-G
Comment options

@ZCY-G
Comment options

@ZCY-G
Comment options

@eddeee888
Comment options

@ZCY-G
Comment options

Answer selected by ZCY-G
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