This is a reporter which sends GraphQL query traces to an Apollo Studio server (formerly Apollo Engine), written in kotlin for the JVM.
The module is available through jcenter
.
With maven:
<dependency>
<groupId>com.gabrielterwesten</groupId>
<artifactId>apollo-engine-reporter</artifactId>
<version>1.2.1</version>
</dependency>
With gradle:
implementation("com.gabrielterwesten:apollo-engine-reporter:1.2.1")
The code snippet below demonstrates the basic usage of the reporter.
val apiKey = "..."
val schema =
"""
type Query {
hello: String
}
""".trimIndent()
val typeDefinitionRegistry = SchemaParser().parse(schema)
val runtimeWiring =
RuntimeWiring.newRuntimeWiring()
.type("Query") {
it.dataFetcher("hello", StaticDataFetcher("World"))
}
.build()
val reporter =
ApolloEngineReporter(
traceShipper = DefaultTraceShipper(apiKey = apiKey),
querySignatureStrategy = DefaultQuerySignatureStrategy,
reportGenerator = DefaultReportGenerator(),
)
reporter.start()
val instrumentation =
ChainedInstrumentation(listOf(
TracingInstrumentation(),
TraceReporterInstrumentation(reporter),
))
val graphQLSchema =
SchemaGenerator().makeExecutableSchema(typeDefinitionRegistry, runtimeWiring)
val execution = GraphQL.newGraphQL(graphQLSchema).instrumentation(instrumentation).build()
val result = execution.execute("query { hello }")
println(result.getData<Any>().toString())
reporter.stop()
apollo-engine-reporter is licensed under the MIT License. See LICENSE for details.