"Type ... cannot be used as an input" compilation error
See original GitHub issueI got compilation errors trying to implement simple mutation api. Possibly I’m doing something wrong but I wasn’t able to figure out what exactly.
Error:
Error:(18, 83) Type sangria.util.tag.@@[me.scf37.graphql1.PermissionInput,sangria.marshalling.FromInput.InputObjectResult] cannot be used as an input. Please consider defining an implicit instance of `FromInput` for it.
implicit val MutationApiType = deriveContextObjectType[Ctx, MutationApi, Unit] {_.mutationApi}
Error:(18, 83) not enough arguments for method createWithoutDefault: (implicit fromInput: sangria.marshalling.FromInput[sangria.util.tag.@@[me.scf37.graphql1.PermissionInput,sangria.marshalling.FromInput.InputObjectResult]], implicit res: sangria.schema.ArgumentType[sangria.util.tag.@@[me.scf37.graphql1.PermissionInput,sangria.marshalling.FromInput.InputObjectResult]])sangria.schema.Argument[res.Res].
Unspecified value parameters fromInput, res.
implicit val MutationApiType = deriveContextObjectType[Ctx, MutationApi, Unit] {_.mutationApi}
Code:
case class Permission(id: String, name: String, description: String)
case class PermissionInput(name: String, description: String)
case class Ctx(mutationApi: MutationApi)
trait MutationApi {
@GraphQLField
def permission(permission: PermissionInput): Permission = ???
}
object Main {
implicit val PermissionType = deriveObjectType[Ctx, Permission]()
implicit val PermissionInputType = deriveInputObjectType[PermissionInput]()
implicit val MutationApiType = deriveContextObjectType[Ctx, MutationApi, Unit] {_.mutationApi}
}
Environment:
scalaVersion := "2.12.1"
Oracle 64-Bit Java "1.8.0_112"
Tried Sangria 1.0.0-RC5 and 4fe3952
sbt 0.13.13
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
C++ input compilation error [closed] - Stack Overflow
I was trying to make a C++ input file on Ideone.com, an online compiler. The program is meant to take in a users...
Read more >How to Handle the Incompatible Types Error in Java - Rollbar
The Java incompatible types error happens when a value assigned to a variable or returned by a method is incompatible with the one...
Read more >function that returns 'auto' cannot be used before it is defined"?
This means “I want the compiler to deduce the return type (but I'm not giving any clues yet).” If you try to call...
Read more >Compilation Errors - Constants, Enumerations and Structures
Compilation Errors ; 285. Structures and arrays cannot be used as input variables ; 286. Const specifier is not valid for constructor/destructor ;...
Read more >Chapter 4. Types, Values, and Variables - Oracle Help Center
Strong static typing helps detect errors at compile time. The types of the Java programming language are divided into two categories: primitive types...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It worked for me. In general, PLEASE consider adding scaladoc at least to public API. All that functional code with heaps of implicits is damn hard to decipher.
When using macros to derive context objects with methods you need to also declare an implicit JSON decoder for each of the input type associated with the method arguments. This is what is hinted in:
If you are using Spray JSON this would be something like: