Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addFieldIdForResolving or customFields option #1276

Open
DobryninVyacheslav opened this issue Jul 22, 2023 · 1 comment
Open

Add addFieldIdForResolving or customFields option #1276

DobryninVyacheslav opened this issue Jul 22, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@DobryninVyacheslav
Copy link

DobryninVyacheslav commented Jul 22, 2023

Is your feature request related to a problem? Please describe.
Let's say we have the following graphql schema (example taken from @thisarattr's question related to this issue):

type Query {
  book(id: ID): Book
}
type Book {
  name: String!
  author: Author
}
type Author {
  name: String!
  age: Int
}

The author should be resolved by a separate request, so I'm adding the following:

fieldsWithResolvers = setOf(
    "Book.author",
)

And get a Book model like:

data class Book(
  val name: String,
)

However, my database stores the author id directly in the book:

class BookEntity(
  val name: String,
  val authorId: String?,
)

So for me it looks more natural to pass id through Book for Author resolving than through GraphQLContext. And, as I understand it, for the author of this comment too.

Describe the solution you'd like
Thus would like to have a model like:

data class Book(
  val name: String,
  val authorId: String?,
)

Maybe it could be the addFieldIdForResolving option.

Describe alternatives you've considered
Or maybe it's better to be able to just set any custom fields (for example, option customFields with mapOf("Book.authorId" to "String") value).

@kobylynskyi
Copy link
Owner

I like more an idea of introducing customFields, because it provides more flexibility (not just Id fields).

@kobylynskyi kobylynskyi added documentation Improvements or additions to documentation enhancement New feature or request and removed documentation Improvements or additions to documentation labels Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants