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

Implementing fields resolver alongside struct fields #1048

Closed
ClementNerma opened this issue Mar 30, 2022 · 1 comment
Closed

Implementing fields resolver alongside struct fields #1048

ClementNerma opened this issue Mar 30, 2022 · 1 comment
Assignees
Labels
duplicate This issue or pull request already exists enhancement Improvement of existing features or bugfix

Comments

@ClementNerma
Copy link

Hi there!

I'm currently using Juniper for an API project and so far the experience has been pretty great!

But I'm currently facing a problem where I need to have a struct with a list of public fields, as well as a few methods that would act as resolvers for the struct itself. Now, the former can be achieved like this:

#[derive(GraphQLObject)]
struct Data {
  // some fields here
}

While the latter can be done like this:

struct Data;

#[graphql_object]
impl Data {
  fn field_resolver() { /* some code here */
}

But how can I achieve both at the same time? Something like:

#[derive(GraphQLObject)]
struct Data {
  // some fields here
}

#[graphql_object]
impl Data {
  fn field_resolver() { /* some code here */
}

doesn't work as it results in a conflicting implementation of GraphQLObject.

@ClementNerma ClementNerma added the enhancement Improvement of existing features or bugfix label Mar 30, 2022
@tyranron tyranron self-assigned this Mar 31, 2022
@tyranron tyranron added the duplicate This issue or pull request already exists label Mar 31, 2022
@tyranron
Copy link
Member

@ClementNerma you cannot achieve this anyhow not in the juniper 0.15, nor in the upcoming 0.16 release. We have plans to allows this, but not in the urgent agenda.

I'm closing this issue as duplicate of #1045 and #646.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement Improvement of existing features or bugfix
Projects
None yet
Development

No branches or pull requests

2 participants