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

Cannot use list-like (Set, Vector, Seq) wrappers as input types #478

Open
theobat opened this issue Jul 1, 2020 · 3 comments
Open

Cannot use list-like (Set, Vector, Seq) wrappers as input types #478

theobat opened this issue Jul 1, 2020 · 3 comments
Labels
feature scope/server morpheus-graphql

Comments

@theobat
Copy link
Contributor

theobat commented Jul 1, 2020

Hey,

I face an issue when I try to use Set Text for example as an input type argument in a query (or a mutation):

|     • No instance for (morpheus-graphql-0.13.0:Data.Morpheus.Server.Deriving.Decode.DecodeKind
|                          Data.Morpheus.Kind.WRAPPER (Set Text))
|         arising from a use of ‘interpreter’

I think it's just a matter of adding the right instance in here

I was thinking something like:

instance Decode a => Decode Set a where
  decode = Set.fromList <$> (withList decode) -- assuming Eventless has a functor instance

As a side note, do you think it would be possible to add a custom wrapper type for the end user (without modifying morpheus) ? Or perhaps a "refiner" so that we can specify length restricted lists for instance ?

Thanks

@theobat theobat changed the title Cannot use list-like wrappers as input types Cannot use list-like (Set, Vector, Seq) wrappers as input types Jul 1, 2020
@theobat
Copy link
Contributor Author

theobat commented Jul 1, 2020

I just saw #341, maybe I can take care of that too along the way

@theobat
Copy link
Contributor Author

theobat commented Jul 1, 2020

#479

@nalchevanidze
Copy link
Member

nalchevanidze commented Jul 1, 2020

the general problem is that graphql does not support custom wrapper types. that why we generate namespaced types for it.

type NonEmpty_Int { 
    elems : [Int] 
}

input NonEmpty_User { 
   elems : [User] 
}

but this schema will fail.

type NonEmpty_Int { 
    elems : [Int] 
}

input NonEmpty_Int { 
   elems : [Int] 
}

that why morpheus graphql should generate type like this:

# for output types
type NonEmpty_output_Int { 
    elems : [Int] 
}

# for input types
input NonEmpty_Input_Int { 
   elems : [Int] 
}

In this case the names do not collide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature scope/server morpheus-graphql
Projects
None yet
Development

No branches or pull requests

2 participants