morpheus-graphql icon indicating copy to clipboard operation
morpheus-graphql copied to clipboard

`gqlDocument` alters the case of GraphQL types and enum values

Open nicuveo opened this issue 3 years ago • 2 comments

gqlDocument does not populate the typeOptions field of the GQLType instance of the generated types in a way that would allow them to preserve their casing.

import Data.ByteString.Lazy   as BSL
import Data.Morpheus.Document
import Data.Morpheus.Server
import Data.Morpheus.Types
import Data.Proxy             (Proxy(..))

[gqlDocument|
type Query {
  foo(bar: order_by): Int!
}

enum order_by { asc, desc }
|]

main =
  BSL.putStr $ printSchema $ Proxy @(RootResolver IO () Query Undefined Undefined)

This prints:

enum Order_by {
  Asc
  Desc
}

type Query {
  foo(bar: Order_by): Int!
}

nicuveo avatar Feb 24 '22 09:02 nicuveo

thanks @nicuveo, it is recommended in GQL that you don't use lowercase type-names. however the behavior is still wrong and worth to fixing it. do you want to fix it? i can give you some pointers, where to start.

nalchevanidze avatar Mar 08 '22 09:03 nalchevanidze

I agree! But it is sometimes required to interface with existing / legacy systems that chose to use lowercase types. ^^

I don't have a lot of bandwidth, but I could try fixing it; if you have some pointers that'd be great!

nicuveo avatar Mar 08 '22 18:03 nicuveo

@nicuveo sorry. i had to fix myself with new directives approach

nalchevanidze avatar Oct 15 '22 11:10 nalchevanidze