GraphQl

GraphQl

The GraphQl interface provides GraphQl query and mutation functionality.

You should use the default functions using Kotlin Coroutines:

val exampleAppQuery: ExampleAppQuery = ExampleAppQuery.builder().build()

fragmentScope.launch {
	smartSpacesSdk.getGraphQl()
		.query(exampleAppQuery)
		.collect { result ->
			result.errors.forEach { error ->
				// do something with the errors
			}

			result.data?.let { data ->
				// do something with the data
			}
		}
}

If you can’t use Coroutines or you are programming Java only, you can use the corresponding functions using Callback:

val cancelable: Cancelable = smartSpacesSdk
	.getGraphQl()
	.queryWithCallback(exampleAppQuery) { result: Result<ExampleAppQuery.Data> ->
		// do something with the result
}

You can pass an optional updateIntervalMillis parameter to the query functions. It will constantly trigger that query in the given interval.

Do not forget calling cancel() on the CoroutineScope or the Cancelable or you will leak memory!