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

[feature request ] Please advance generic types as they are pretty useless at this time #186

Closed
trsh opened this issue May 18, 2018 · 2 comments
Labels
enhancement Improvement of existing features or bugfix

Comments

@trsh
Copy link

trsh commented May 18, 2018

This is cool example from docs

struct GenericType<T> { items: Vec<T> }

graphql_object!(<T> GenericType<T>: () as "GenericType" |&self| {
    field count() -> i32 { self.items.len() as i32 }
});

bit can't use it like

graphql_object!(<T> Listt<T>: () as "Listt" |&self| {
   ......
    field edges() -> Vec<T> {
        self.edges
    }
});

what gives an ^ the trait juniper::GraphQLType is not implemented for T error.
So it make little sense for me, if I can't use the generic as another GraphQLType in object macro.

#[derive(GraphQLInputObject)]
pub struct Paging<T> {
    pub first: i32,
    pub page: T,
}

Macro doesn't support this and neither this:

#[derive(GraphQLObject)]
struct NewConstant<T> {
    id: String,
    value: T,
}

To make this happen I had to drop Macro and generate a lot of boilerplate code. So it would be nice to see this kind of support in future.

@LegNeato LegNeato added the enhancement Improvement of existing features or bugfix label May 23, 2018
@ForsakenHarmony
Copy link

ForsakenHarmony commented May 30, 2018

well for the macro you're gonna have to put a bound on the generic type so it can only be a type that impls GraphQLType

then again what's the actual intention here? graphql itself doesn't have generic types

@LegNeato
Copy link
Member

I believe the second part was fixed in #226 and the first part does not appear actionable.

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

No branches or pull requests

3 participants