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

what is the best way to organize root resolvers? #934

Closed
videni opened this issue May 24, 2021 · 0 comments
Closed

what is the best way to organize root resolvers? #934

videni opened this issue May 24, 2021 · 0 comments

Comments

@videni
Copy link

videni commented May 24, 2021

I try to create two root resolvers in different file.

create_customer.rs

#[graphql_object(context = Context)]
impl Mutation {
    async fn create_customer(
        context: &Context,
        customer: CustomerCreateInput,
    ) -> FieldResult<CreateCustomerResult> {
}
}

If I don't put another graphql_object attribute, then rust will complain generate_customer_token not used.
generate_customer_token.rs

#[graphql_object(context = Context)]
impl Mutation {
    async fn generate_customer_token(
        context: &Context,
        username: String,
        password: String,
    ) -> FieldResult<CustomerToken> {
}

I got

{
	"resource": "/Users/acme/www/test/src/resolver/create_customer.rs",
	"owner": "rustc",
	"code": {
		"value": "E0119",
		"target": {
			"$mid": 1,
			"external": "https://doc.rust-lang.org/error-index.html#E0119",
			"path": "/error-index.html",
			"scheme": "https",
			"authority": "doc.rust-lang.org",
			"fragment": "E0119"
		}
	},
	"severity": 8,
	"message": "conflicting implementations of trait `juniper::GraphQLValueAsync<_>` for type `graphql::Mutation`\nconflicting implementation for `graphql::Mutation`",
	"source": "rustc",
	"startLineNumber": 46,
	"startColumn": 1,
	"endLineNumber": 46,
	"endColumn": 37,
	"relatedInformation": [
		{
			"startLineNumber": 18,
			"startColumn": 1,
			"endLineNumber": 18,
			"endColumn": 37,
			"message": "first implementation here",
			"resource": "/Users/acme/www/test/src/resolver/generate_customer_token.rs"
		}
	]
}

I am very curious, is your project really that simple you can put all your root resolvers in a single file?

@videni videni changed the title what is the best way to organize resolver? what is the best way to organize root resolvers? May 26, 2021
@videni videni closed this as completed May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant