-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with wrong Action[Ctx, _] conversion being summoned
- Loading branch information
Showing
5 changed files
with
128 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
modules/derivation/src/test/scala/sangria/macros/derive/Issue906Context.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package sangria.macros.derive | ||
|
||
import sangria.schema._ | ||
|
||
import scala.concurrent.Future | ||
|
||
object Issue906Context { | ||
|
||
@GraphQLName("SampleCaseClass") | ||
@GraphQLDescription("A sample case class") | ||
final case class SampleCaseClass( | ||
name: String | ||
) { | ||
@GraphQLField | ||
@GraphQLName("myString") | ||
def graphqlMyString: String = "Hello World" | ||
|
||
@GraphQLField | ||
@GraphQLName("myFutureString") | ||
def graphqlMyFutureString: Future[String] = Future.successful("Hello World") | ||
|
||
} | ||
|
||
object SampleCaseClass { | ||
val sample: SampleCaseClass = SampleCaseClass("My test") | ||
} | ||
|
||
trait MyRepository { | ||
def getSampleCaseClass: SampleCaseClass | ||
} | ||
|
||
object MyRepository { | ||
def sample: MyRepository = new MyRepository { | ||
override def getSampleCaseClass: SampleCaseClass = SampleCaseClass.sample | ||
} | ||
} | ||
|
||
object MySample { | ||
val schema: Schema[MyRepository, Unit] = { | ||
|
||
implicit val graphqlSampleCaseClass: ObjectType[MyRepository, SampleCaseClass] = | ||
deriveObjectType[MyRepository, SampleCaseClass]() | ||
|
||
val queries: ObjectType[MyRepository, Unit] = ObjectType( | ||
"Query", | ||
fields( | ||
Field( | ||
"mySample", | ||
graphqlSampleCaseClass, | ||
Some("test"), | ||
arguments = Nil, | ||
resolve = (ctx: Context[MyRepository, Unit]) => SampleCaseClass.sample | ||
) | ||
) | ||
) | ||
|
||
Schema( | ||
query = queries, | ||
mutation = None, | ||
additionalTypes = Nil | ||
) | ||
} | ||
} | ||
} |