#Can someone explain how dagger sdks and
1 messages · Page 1 of 1 (latest)
There's very early work on a Java SDK (no modules), but not Kotlin. 🙂
Short answer: Yes, it can be compiled, it’s up to the SDK. “Translation” happens via API calls that are specifically for use by SDKs.
Longer answer, i.e., how it works?
For modules, each SDK defines a module to create a container that knows how to run code in the supported language. So a Kotlin SDK would have a kotlin-sdk module, written in another SDK (usually in Go), with a function that returns a container that can run Kotlin code. That container defines an entrypoint executable that the engine calls every time you need to load a module that uses said SDK. This entrypoint is usually written in the language the SDK supports, so it can be in Kotlin.
The entrypoint executable then makes API calls that are specifically for use by SDKs only. From these API calls you can get what function you're supposed to invoke, with which inputs, and you send the result back to the API before exiting the executable. It's the same thing whether you're supposed to register the types of the module, instead of invoking a function.
In the case of registration, for example, the entrypoint needs to be able to introspect the module's code (the code in the module that uses this SDK, as in dagger init --sdk=kotlin), and make API calls to tell the engine which objects, functions, enums, etc, exist. This includes names, descriptions, return types, etc.
From these API calls, the engine extends the current GraphQL schema, with the module's own types and functions.