muuki88 / sbt-graphql

SBT plugin to generate and validate graphql schemas written with Sangria
Apache License 2.0
96 stars 20 forks source link

Fixes #65 #66

Closed NicolasRouquette closed 5 years ago

muuki88 commented 5 years ago

Thanks for your pull request :hugs:

Is this a custom type in your code base? If so then you should solve this by importing the required types with graphqlCodegenImports. See https://github.com/muuki88/sbt-graphql#scalar-types

NicolasRouquette commented 5 years ago

The github schema defines a scalar type: URI. With graphqlCodegenImports += "java.net.URI", I get errors because there is no circe decoder available.

Perhaps this could be remedied with another import. For the time being, the simplest is to handle URI just like ID, i.e., as an alias to String.

muuki88 commented 5 years ago

I understand your intention, but adding types from a specific schema into the generic code generation is IMHO not good solution as this may break others that actually have a valid URI type and types for it.

What should work is the following

package com.github.graphql

object types {
   type URI = String
}

in your build.sbt

graphqlCodegenImports += "com.github.graphql.types._"

WDYT?

muuki88 commented 5 years ago

Closing this. We shouldn't add magic behaviour for random types. If there's a better way to handle these scenarios than the current options, I'm open for suggestions and pull requests :)