// Get the current logged-in user
val context = CurrentUser(getUserIdFromHttpHeaders())
@@ -43,7 +43,7 @@
.build(),
context
)
-
CurrentUser is now available in Query.viewer:
+
CurrentUser is now available in Query.viewer:
class Query {
fun viewer(context: ExecutionContext): User {
val id = context[CurrentUser]!!.id
diff --git a/federation.html b/federation.html
index f055e6d..0f7d989 100644
--- a/federation.html
+++ b/federation.html
@@ -1,5 +1,5 @@
-Apollo Federation | Apollo Kotlin Execution
Whenever a type containing a @GraphQLKey field is present, Apollo Kotlin Execution adds the federation subgraph fields, _service and _entities:
+
Auto-generated meta fields
Whenever a type containing a @GraphQLKey field is present, Apollo Kotlin Execution adds the federation subgraph fields, _service and _entities:
# an union containing all the federated types in the schema, constructed at build time
union _Entity = Product | ...
# coerced as a JSON object containing '__typename' and all the key fields.
@@ -44,7 +44,7 @@
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
-
Defining entity resolvers
In order to support the _entities field, federation requires a resolver that can resolve an entity from its key fields.
You can add one by defining a resolve function on the companion object:
+
Defining entity resolvers
In order to support the _entities field, federation requires a resolver that can resolve an entity from its key fields.
You can add one by defining a resolve function on the companion object:
class Product(
@GraphQLKey
val id: String,
@@ -61,7 +61,7 @@
Product("1", "foo"),
Product("2", "bar")
)
-
Just like regular resolvers, the entity resolvers can be suspend and/or have an ExecutionContext parameter:
+
Just like regular resolvers, the entity resolvers can be suspend and/or have an ExecutionContext parameter:
class Product(
@GraphQLKey
val id: String,
@@ -73,7 +73,7 @@
}
}
}
-
Ftv1 records timing information for each field and reports that information to the router through the "ftv1" extension.
To enable federated tracing, configure your ExecutableSchema with a Ftv1Instrumentation and matching Ftv1Context:
// Install the Ftv1Instrumentation in the executable schema
val schema = ServiceExecutableSchemaBuilder()
.addInstrumentation(Ftv1Instrumentation())
@@ -85,7 +85,7 @@
// The information is a Base64 encoded protobuf message used by the router
val ftv1 = response.extensions.get("ftv1")
-
Sending the "ftv1" extension has some overhead and in real life scenarios, the router uses sampling to save network bandwidth.
This is done using the "apollo-federation-include-trace" HTTP header:
+
Sending the "ftv1" extension has some overhead and in real life scenarios, the router uses sampling to save network bandwidth.
This is done using the "apollo-federation-include-trace" HTTP header:
val ftv1Context = if (httpHeaders.get("apollo-federation-include-trace") == "ftv1") {
// The router required tracing information for this request
Ftv1Context()
diff --git a/getting-started.html b/getting-started.html
index 3195fa0..e2c8295 100644
--- a/getting-started.html
+++ b/getting-started.html
@@ -1,5 +1,5 @@
-Getting started | Apollo Kotlin Execution
Apollo Kotlin Execution Help
Getting started
Apollo Kotlin Execution is a code-first GraphQL execution library.
Apollo Kotlin Execution:
Generates a GraphQL schema from your Kotlin code: write Kotlin, get a typesafe API.
Doesn't use reflection. Use it on the JVM and enjoy ultra-fast start times. Or use it with Kotlin native. Apollo Kotlin Execution is KMP-ready!
Supports custom scalars, subscriptions, persisted queries and everything in the current GraphQL draft.
\ No newline at end of file
diff --git a/http4k.html b/http4k.html
index 2b92047..1034e6a 100644
--- a/http4k.html
+++ b/http4k.html
@@ -1,5 +1,5 @@
-http4k | Apollo Kotlin Execution
Apollo Kotlin Execution Help
http4k
To use the http4k integration, add apollo-execution-http4k to your dependencies and the http4k bom:
+}
Apollo Kotlin Execution Help
http4k
To use the http4k integration, add apollo-execution-http4k to your dependencies and the http4k bom:
dependencies {
// Add the runtime dependency
implementation("com.apollographql.execution:apollo-execution-http4k:0.1.0")
@@ -24,10 +24,10 @@
// See https://www.http4k.org/guide/reference/servers/
implementation("org.http4k:http4k-server-netty")
}
-
apollo-execution-ktor provides an apolloHandler(ExecutableSchema) function that handles the /graphql route:
+
apollo-execution-ktor provides an apolloHandler(ExecutableSchema) function that handles the /graphql route:
val executableSchema = ServiceExecutableSchemaBuilder().build()
apolloHandler(executableSchema)
.asServer(Netty(8000))
.start()
.block()
-
\ No newline at end of file
diff --git a/ide.html b/ide.html
index e4a84bb..e2e9fe0 100644
--- a/ide.html
+++ b/ide.html
@@ -1,5 +1,5 @@
-IDE | Apollo Kotlin Execution
Apollo Kotlin Execution Help
IDE
One of GraphQL strong points is tooling.
Apollo Kotlin Execution comes with a built-in IDE that makes it easy to explore your schema and debug your operations.
You can get a ready-to-serve version of Apollo Sandbox using the sandboxHtml() function:
+}
Apollo Kotlin Execution Help
IDE
Apollo Kotlin Execution comes with a built-in IDE that makes it easy to explore your schema, write your operation with autocomplete and execute them.
You can get a ready-to-serve version of Apollo Sandbox using the sandboxHtml() function:
val pageTitle = "Welcome to my API"
val initialEndpoint = "http://localhost:8080/graphql"
-sandboxHtml(title = pageTitle, initialEndpoint = initialEndpoint)
-
You can then serve it using your favorite server or use any of the existing integrations:
\ No newline at end of file
+val html = sandboxHtml(title = pageTitle, initialEndpoint = initialEndpoint)
+
+// Expose this graphql to your route of choice, /sandbox for an example
+get("/sandbox") {
+ respondHtml(html)
+}
+
The builtin integrations provide helper functions for this: