diff --git a/HelpTOC.json b/HelpTOC.json index 8a3c1411..1729bad4 100644 --- a/HelpTOC.json +++ b/HelpTOC.json @@ -1 +1 @@ -{"entities":{"pages":{"sz3asd_2":{"id":"sz3asd_2","title":"GitHub","url":"https://github.com/apollographql/apollo-kotlin-execution","level":0,"tabIndex":0},"sz3asd_3":{"id":"sz3asd_3","title":"Kdoc","url":"https://apollographql.github.io/apollo-kotlin-execution/kdoc","level":0,"tabIndex":1},"sz3asd_4":{"id":"sz3asd_4","title":"Welcome","level":0,"pages":["getting-started","schema","scalars","execution-context","persisted-documents","ide","schema-dump"],"tabIndex":2},"getting-started":{"id":"getting-started","title":"Getting started","url":"getting-started.html","level":1,"parentId":"sz3asd_4","tabIndex":0},"schema":{"id":"schema","title":"Generating a schema","url":"schema.html","level":1,"parentId":"sz3asd_4","tabIndex":1},"scalars":{"id":"scalars","title":"Custom scalars","url":"scalars.html","level":1,"parentId":"sz3asd_4","tabIndex":2},"execution-context":{"id":"execution-context","title":"Execution context","url":"execution-context.html","level":1,"parentId":"sz3asd_4","tabIndex":3},"persisted-documents":{"id":"persisted-documents","title":"Persisted documents","url":"persisted-documents.html","level":1,"parentId":"sz3asd_4","tabIndex":4},"ide":{"id":"ide","title":"IDE","url":"ide.html","level":1,"parentId":"sz3asd_4","tabIndex":5},"schema-dump":{"id":"schema-dump","title":"Monitoring the generated schema","url":"schema-dump.html","level":1,"parentId":"sz3asd_4","tabIndex":6},"sz3asd_5":{"id":"sz3asd_5","title":"Integrations","level":0,"pages":["ktor","http4k","spring"],"tabIndex":3},"ktor":{"id":"ktor","title":"Ktor","url":"ktor.html","level":1,"parentId":"sz3asd_5","tabIndex":0},"http4k":{"id":"http4k","title":"http4k","url":"http4k.html","level":1,"parentId":"sz3asd_5","tabIndex":1},"spring":{"id":"spring","title":"Spring","url":"spring.html","level":1,"parentId":"sz3asd_5","tabIndex":2},"sz3asd_6":{"id":"sz3asd_6","title":"Apollo Federation","level":0,"pages":["federation"],"tabIndex":4},"federation":{"id":"federation","title":"Apollo Federation","url":"federation.html","level":1,"parentId":"sz3asd_6","tabIndex":0},"sz3asd_7":{"id":"sz3asd_7","title":"Apollo Usage Reporting","level":0,"pages":["usage-reporting"],"tabIndex":5},"usage-reporting":{"id":"usage-reporting","title":"Apollo Usage Reporting","url":"usage-reporting.html","level":1,"parentId":"sz3asd_7","tabIndex":0}}},"topLevelIds":["sz3asd_2","sz3asd_3","sz3asd_4","sz3asd_5","sz3asd_6","sz3asd_7"]} \ No newline at end of file +{"entities":{"pages":{"miiaz6_2":{"id":"miiaz6_2","title":"GitHub","url":"https://github.com/apollographql/apollo-kotlin-execution","level":0,"tabIndex":0},"miiaz6_3":{"id":"miiaz6_3","title":"Kdoc","url":"https://apollographql.github.io/apollo-kotlin-execution/kdoc","level":0,"tabIndex":1},"miiaz6_4":{"id":"miiaz6_4","title":"Welcome","level":0,"pages":["getting-started","schema","scalars","execution-context","persisted-documents","ide","schema-dump"],"tabIndex":2},"getting-started":{"id":"getting-started","title":"Getting started","url":"getting-started.html","level":1,"parentId":"miiaz6_4","tabIndex":0},"schema":{"id":"schema","title":"Generating a schema","url":"schema.html","level":1,"parentId":"miiaz6_4","tabIndex":1},"scalars":{"id":"scalars","title":"Custom scalars","url":"scalars.html","level":1,"parentId":"miiaz6_4","tabIndex":2},"execution-context":{"id":"execution-context","title":"Execution context","url":"execution-context.html","level":1,"parentId":"miiaz6_4","tabIndex":3},"persisted-documents":{"id":"persisted-documents","title":"Persisted documents","url":"persisted-documents.html","level":1,"parentId":"miiaz6_4","tabIndex":4},"ide":{"id":"ide","title":"IDE","url":"ide.html","level":1,"parentId":"miiaz6_4","tabIndex":5},"schema-dump":{"id":"schema-dump","title":"Monitoring the generated schema","url":"schema-dump.html","level":1,"parentId":"miiaz6_4","tabIndex":6},"miiaz6_5":{"id":"miiaz6_5","title":"Integrations","level":0,"pages":["ktor","http4k","spring"],"tabIndex":3},"ktor":{"id":"ktor","title":"Ktor","url":"ktor.html","level":1,"parentId":"miiaz6_5","tabIndex":0},"http4k":{"id":"http4k","title":"http4k","url":"http4k.html","level":1,"parentId":"miiaz6_5","tabIndex":1},"spring":{"id":"spring","title":"Spring","url":"spring.html","level":1,"parentId":"miiaz6_5","tabIndex":2},"miiaz6_6":{"id":"miiaz6_6","title":"Apollo Federation","level":0,"pages":["federation"],"tabIndex":4},"federation":{"id":"federation","title":"Apollo Federation","url":"federation.html","level":1,"parentId":"miiaz6_6","tabIndex":0},"miiaz6_7":{"id":"miiaz6_7","title":"Apollo Usage Reporting","level":0,"pages":["usage-reporting"],"tabIndex":5},"usage-reporting":{"id":"usage-reporting","title":"Apollo Usage Reporting","url":"usage-reporting.html","level":1,"parentId":"miiaz6_7","tabIndex":0}}},"topLevelIds":["miiaz6_2","miiaz6_3","miiaz6_4","miiaz6_5","miiaz6_6","miiaz6_7"]} \ No newline at end of file diff --git a/execution-context.html b/execution-context.html index 0a95ef72..04be97c0 100644 --- a/execution-context.html +++ b/execution-context.html @@ -1,5 +1,5 @@ -Execution context | Apollo Kotlin Execution

Apollo Kotlin Execution Help

Execution context

Kotlin functions may define an additional ExecutionContext parameter. This parameter is special and never exposed in GraphQL.

Kotlin

GraphQL

+}

Apollo Kotlin Execution Help

Execution context

Kotlin functions may define an additional ExecutionContext parameter. This parameter is special and never exposed in GraphQL.

Kotlin

GraphQL

@GraphQLQuery class Query { fun viewer(context: ExecutionContext): User { @@ -21,19 +21,19 @@ return user } } -
+
type Query { # this field has no arguments viewer: user } -

ExecutionContext is a typesafe map inspired by CoroutinesContext. Define your own context by extending ExecutionContext.Element:

+

ExecutionContext is a typesafe map inspired by CoroutinesContext. Define your own context by extending ExecutionContext.Element:

class CurrentUser(val id: String) : ExecutionContext.Element { override val key: ExecutionContext.Key<*> get() = Key companion object Key : ExecutionContext.Key<CurrentUser> } -

And pass it to ExecutableSchema.execute():

+

And pass it to ExecutableSchema.execute():

// 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 c678b52b..18a77b86 100644 --- a/federation.html +++ b/federation.html @@ -1,5 +1,5 @@ -Apollo Federation | Apollo Kotlin Execution

Apollo Kotlin Execution Help

Apollo Federation

Apollo Kotlin Execution supports Apollo Federation.

To use federation, add the apollo-execution-subgraph artifact to your project:

+}

Apollo Kotlin Execution Help

Apollo Federation

Apollo Kotlin Execution supports Apollo Federation.

To use federation, add the apollo-execution-subgraph artifact to your project:

dependencies { // Add the federation dependency implementation("com.apollographql.execution:apollo-execution-subgraph:0.1.0") } -

The apollo-execution-subgraph artifact contains the @GraphQLKey annotation allowing you to define entities.

Defining entities

You can define an entity key using the @GraphQLKey annotation:

+

The apollo-execution-subgraph artifact contains the @GraphQLKey annotation allowing you to define entities.

Defining entities

You can define an entity key using the @GraphQLKey annotation:

class Product( @GraphQLKey val id: String, val name: String ) -

The @GraphQLKey annotation is translated at build time into a matching federation @key directive:

+

The @GraphQLKey annotation is translated at build time into a matching federation @key directive:

@key(fields: "id") type Product { id: String!, name: String! } -

Auto-generated meta fields

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 @@ } } } -

Tracing (ftv1)

Apollo Kotlin Execution supports federated tracing (ftv1).

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:

+

Tracing (ftv1)

Apollo Kotlin Execution supports federated tracing (ftv1).

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() @@ -95,4 +95,4 @@ } val response = schema.execute(request, ftv1Context) -
Last modified: 31 October 2024
\ No newline at end of file +
Last modified: 08 November 2024
\ No newline at end of file diff --git a/getting-started.html b/getting-started.html index bf2bd35c..9d8f3dd0 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.

  • Integrates with Ktor, http4k and Spring.

  • Supports Apollo Federation.

Under the hood, Apollo Kotlin Execution uses KSP to generate GraphQL resolvers and types from your Kotlin code.

Gradle configuration

Apollo Kotlin Execution comes with a Gradle plugin that:

  • Configures KSP:

    • Adds apollo-execution-processor to the KSP configuration.

    • Configure service & packageName KSP arguments.

  • Configures dependency resolution to align Apollo Kotlin Execution versions if none is specified.

  • Adds apolloCheckSchema and apolloDumpSchema tasks (see Monitoring the generated schema)

Configure your Gradle build:

+}

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.

  • Integrates with Ktor, http4k and Spring.

  • Supports Apollo Federation.

Under the hood, Apollo Kotlin Execution uses KSP to generate GraphQL resolvers and types from your Kotlin code.

Gradle configuration

Apollo Kotlin Execution comes with a Gradle plugin that:

  • Configures KSP:

    • Adds apollo-execution-processor to the KSP configuration.

    • Configure service & packageName KSP arguments.

  • Configures dependency resolution to align Apollo Kotlin Execution versions if none is specified.

  • Adds apolloCheckSchema and apolloDumpSchema tasks (see Monitoring the generated schema)

Configure your Gradle build:

// build.gradle.kts plugins { // Kotlin and KSP are required @@ -34,9 +34,9 @@ packageName = "com.example" } } -

Disable KSP for tests (doc):

+

Disable KSP for tests (doc):

ksp.allow.all.target.configuration=false -

Define your root query

Write your root query class in a Query.kt file:

+

Define your root query

Write your root query class in a Query.kt file:

// @GraphQLQuery is the entry point for KSP processing @GraphQLQuery class Query { @@ -50,18 +50,18 @@ return "Hello $name" } } -

Run the codegen:

+

Run the codegen:

./gradlew kspKotlin # or if multiplatform ./gradlew kspCommonMainKotlinMetadata -

Execute your query

The codegen generates a com.example.ServiceExecutableSchemaBuilder class that is the entry point to execute GraphQL requests:

+

Execute your query

The codegen generates a com.example.ServiceExecutableSchemaBuilder class that is the entry point to execute GraphQL requests:

val executableSchema = ServiceExecutableSchemaBuilder() .build() -

Create a GraphQL request:

+

Create a GraphQL request:

val request = GraphQLRequest.Builder() .document("{ hello(name: \"sample\") }") .build() -

Execute the GraphQL request:

+

Execute the GraphQL request:

val response = executableSchema.execute( request, ExecutionContext.Empty @@ -69,4 +69,4 @@ println(response.data) // {hello=Hello sample} -

Apollo Kotlin Execution supports objects, interfaces, unions, enum, input objects, deprecation, customizing names and descriptions and more.

See the Generating a schema page for more details.

Integrate with your favorite server library

Apollo Kotlin Execution comes with integrations for popular server libraries:

See the respective documentation for how to configure a server with an ExecutableSchema.

Last modified: 25 November 2024
\ No newline at end of file +

Apollo Kotlin Execution supports objects, interfaces, unions, enum, input objects, deprecation, customizing names and descriptions and more.

See the Generating a schema page for more details.

Integrate with your favorite server library

Apollo Kotlin Execution comes with integrations for popular server libraries:

See the respective documentation for how to configure a server with an ExecutableSchema.

Last modified: 25 November 2024
\ No newline at end of file diff --git a/http4k.html b/http4k.html index 500257f2..6620d461 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() -
Last modified: 29 August 2024
\ No newline at end of file +
Last modified: 29 August 2024
\ No newline at end of file diff --git a/ide.html b/ide.html index 61e15d68..f3f635bc 100644 --- a/ide.html +++ b/ide.html @@ -1,5 +1,5 @@ -IDE | Apollo Kotlin Execution

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:

+}

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" @@ -23,4 +23,4 @@ get("/sandbox") { respondHtml(html) } -

Apollo Sandbox

The builtin integrations provide helper functions for this:

Last modified: 08 November 2024
\ No newline at end of file +

Apollo Sandbox

The builtin integrations provide helper functions for this:

Last modified: 08 November 2024
\ No newline at end of file diff --git a/kdoc/apollo-execution-gradle-plugin/navigation.html b/kdoc/apollo-execution-gradle-plugin/navigation.html index 1d47f8d0..a4fd2f96 100644 --- a/kdoc/apollo-execution-gradle-plugin/navigation.html +++ b/kdoc/apollo-execution-gradle-plugin/navigation.html @@ -97,12 +97,17 @@ apolloSandboxModule() -
+
+ +
+
-
+
diff --git a/kdoc/apollo-execution-http4k/navigation.html b/kdoc/apollo-execution-http4k/navigation.html index 1d47f8d0..a4fd2f96 100644 --- a/kdoc/apollo-execution-http4k/navigation.html +++ b/kdoc/apollo-execution-http4k/navigation.html @@ -97,12 +97,17 @@ apolloSandboxModule()
-
+ + -
+
diff --git a/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/apollo-subscription-module.html b/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/apollo-subscription-module.html new file mode 100644 index 00000000..fa127146 --- /dev/null +++ b/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/apollo-subscription-module.html @@ -0,0 +1,76 @@ + + + + + apolloSubscriptionModule + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ +
+

apolloSubscriptionModule

+
+
fun <Error class: unknown class>.apolloSubscriptionModule(executableSchema: <Error class: unknown class>, path: String = "/subscription", executionContext: (<Error class: unknown class>) -> <Error class: unknown class> = { ExecutionContext.Empty })
+
+ +
+
+
+ + + diff --git a/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/index.html b/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/index.html index f0c7061c..ae969ca5 100644 --- a/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/index.html +++ b/kdoc/apollo-execution-ktor/com.apollographql.execution.ktor/index.html @@ -98,6 +98,21 @@

Functions

+ +
+
+
+ + +
Link copied to clipboard
+
+
+
+
fun <Error class: unknown class>.apolloSubscriptionModule(executableSchema: <Error class: unknown class>, path: String = "/subscription", executionContext: (<Error class: unknown class>) -> <Error class: unknown class> = { ExecutionContext.Empty })
+
+
+
+
diff --git a/kdoc/apollo-execution-ktor/navigation.html b/kdoc/apollo-execution-ktor/navigation.html index 1d47f8d0..a4fd2f96 100644 --- a/kdoc/apollo-execution-ktor/navigation.html +++ b/kdoc/apollo-execution-ktor/navigation.html @@ -97,12 +97,17 @@ apolloSandboxModule()
-
+ + -
+
diff --git a/kdoc/apollo-execution-processor/navigation.html b/kdoc/apollo-execution-processor/navigation.html index 1d47f8d0..a4fd2f96 100644 --- a/kdoc/apollo-execution-processor/navigation.html +++ b/kdoc/apollo-execution-processor/navigation.html @@ -97,12 +97,17 @@ apolloSandboxModule()
-
+ + -
+
diff --git a/kdoc/apollo-execution-reporting/navigation.html b/kdoc/apollo-execution-reporting/navigation.html index 1d47f8d0..a4fd2f96 100644 --- a/kdoc/apollo-execution-reporting/navigation.html +++ b/kdoc/apollo-execution-reporting/navigation.html @@ -97,12 +97,17 @@ apolloSandboxModule()
-
+ + -
+
diff --git a/kdoc/apollo-execution-runtime/com.apollographql.execution.websocket/-subscription-web-socket-handler/-subscription-web-socket-handler.html b/kdoc/apollo-execution-runtime/com.apollographql.execution.websocket/-subscription-web-socket-handler/-subscription-web-socket-handler.html index e8235001..3f8e0653 100644 --- a/kdoc/apollo-execution-runtime/com.apollographql.execution.websocket/-subscription-web-socket-handler/-subscription-web-socket-handler.html +++ b/kdoc/apollo-execution-runtime/com.apollographql.execution.websocket/-subscription-web-socket-handler/-subscription-web-socket-handler.html @@ -58,12 +58,12 @@
-
+

SubscriptionWebSocketHandler

-
constructor(executableSchema: ExecutableSchema, scope: CoroutineScope, executionContext: ExecutionContext, sendMessage: (WebSocketMessage) -> Unit, connectionInitHandler: ConnectionInitHandler = { ConnectionInitAck })
+
constructor(executableSchema: ExecutableSchema, scope: CoroutineScope, executionContext: ExecutionContext, sendMessage: suspend (WebSocketMessage) -> Unit, connectionInitHandler: ConnectionInitHandler = { ConnectionInitAck })