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

Specify GQLType __name? #558

Closed
jaredramirez opened this issue Nov 20, 2020 · 2 comments · Fixed by #569
Closed

Specify GQLType __name? #558

jaredramirez opened this issue Nov 20, 2020 · 2 comments · Fixed by #569
Labels
feature good first issue Good for newcomers help wanted Extra attention is needed scope/server morpheus-graphql

Comments

@jaredramirez
Copy link

Hey, thanks for the great library!

Is it possible to specify the GQLType name? Looking through the source, it looks like it'd be possible if Data.Morpheus.Server.Types.GQLType exposed mkTypeData and GQLType exposed __type.

My use case is that I use a single ID type for all of my DB ids with a phantom type to ensure type safety:

newtype Id phantom = Id UUID

-- specify all my instances once, rather then for every id type

data UserIdPhantom
type UserId = Id UserIdPhantom

data AccountIdPhantom
type AccountId = Id AccountIdPhantom

This works great, but moprheus generates GQL type names for this like Id_UserIdPhantom and Id_AccountIdPhantom. This is fine, but on the client it's a bit vebose to read and the client doesn't really care about the phantom stuff. I think the names are coming from from Data.Morpheus.Server.Types.GQLType.deriveTypeData and Typeable. It would be cool if I could override this with something like:

instance GQLType UserId where
  type KIND UserId = SCALAR
  __type _ = mkTypeData "UserId"
@nalchevanidze
Copy link
Member

nalchevanidze commented Nov 20, 2020

thank you @jaredramirez!

__type is hidden because of some reasons (one of which is safety). i think we could use for modifications like this GQLTypeOptions.

data GQLTypeOptions = GQLTypeOptions

you can add new field : typeNameModifier :: String -> String

data GQLTypeOptions = GQLTypeOptions
  { ...
    typeNameModifier :: String -> String
  }

@nalchevanidze nalchevanidze added scope/server morpheus-graphql good first issue Good for newcomers help wanted Extra attention is needed labels Dec 4, 2020
@bradsherman
Copy link
Contributor

Hi, I'd like to try and solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue Good for newcomers help wanted Extra attention is needed scope/server morpheus-graphql
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants