removed graphql-interceptor module

This commit is contained in:
Florent Champigny 2025-08-02 13:10:20 +02:00
parent 32d462f3e5
commit 559443c529
10 changed files with 0 additions and 253 deletions

View file

@ -50,12 +50,10 @@ dependencies {
implementation("io.github.openflocon:flocon:$floconVersion")
implementation("io.github.openflocon:flocon-grpc-interceptor:$floconVersion")
implementation("io.github.openflocon:flocon-okhttp-interceptor:$floconVersion")
implementation("io.github.openflocon:flocon-graphql-interceptor:$floconVersion")
} else {
implementation(project(":core"))
implementation(project(":okhttp-interceptor"))
implementation(project(":grpc-interceptor"))
implementation(project(":graphql-interceptor"))
}

View file

@ -8,7 +8,6 @@ import com.apollographql.apollo.network.http.HttpInterceptorChain
import com.apollographql.apollo.network.okHttpClient
import com.github.GetUserInfoQuery
import io.github.openflocon.flocon.myapplication.BuildConfig
import io.github.openflocon.flocon.okhttp.FloconApolloInterceptor
import okhttp3.OkHttpClient
class GraphQlTester(val client: OkHttpClient) {

View file

@ -1 +0,0 @@
/build

View file

@ -1,92 +0,0 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
id("com.vanniktech.maven.publish") version "0.34.0"
}
android {
namespace = "io.github.openflocon.flocon.graphql"
compileSdk = 36
defaultConfig {
minSdk = 24
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}
dependencies {
implementation(project(":core"))
// not sure
implementation(libs.androidx.core.ktx)
implementation(platform(libs.kotlinx.coroutines.bom))
implementation(libs.jetbrains.kotlinx.coroutines.core)
implementation(libs.jetbrains.kotlinx.coroutines.android)
implementation(libs.apollo.runtime)
}
mavenPublishing {
publishToMavenCentral()
if (project.hasProperty("signing.required") && project.property("signing.required") == "false") {
// Skip signing
} else {
signAllPublications()
}
coordinates(
groupId = project.property("floconGroupId") as String,
artifactId = "flocon-graphql-interceptor",
version = project.property("floconVersion") as String
)
pom {
name = "Flocon Graphql Interceptor"
description = project.property("floconDescription") as String
inceptionYear = "2025"
url = "https://github.com/openflocon/Flocon"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "openflocon"
name = "Open Flocon"
url = "https://github.com/openflocon"
}
}
scm {
url = "https://github.com/openflocon/Flocon"
connection = "scm:git:git://github.com/openflocon/Flocon.git"
developerConnection = "scm:git:ssh://git@github.com/openflocon/Flocon.git"
}
}
}

View file

@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View file

@ -1,91 +0,0 @@
package io.github.openflocon.flocon.okhttp
import com.apollographql.apollo.api.http.ByteStringHttpBody
import io.github.openflocon.flocon.Flocon
import io.github.openflocon.flocon.Protocol
import io.github.openflocon.flocon.okhttp.model.FloconGrpcRequest
import com.apollographql.apollo.api.http.HttpMethod
import com.apollographql.apollo.api.http.HttpRequest
import com.apollographql.apollo.api.http.HttpResponse
import com.apollographql.apollo.network.http.HttpInterceptor
import com.apollographql.apollo.network.http.HttpInterceptorChain
import okio.Buffer
import java.nio.charset.StandardCharsets
class FloconApolloInterceptor(
private val floconClient: Flocon.Client? = null,
) : HttpInterceptor {
override suspend fun intercept(request: HttpRequest, chain: HttpInterceptorChain): HttpResponse {
val requestedAt = System.currentTimeMillis()
val requestHeadersMap = request.headers.associate { it.name to it.value }
val startTime = System.nanoTime()
var requestBodyString: String? = null
val requestBody = request.body
val newRequest = if (requestBody == null) {
request
} else {
val buffer = Buffer()
requestBody.writeTo(buffer)
val bodyByteString = buffer.readByteString()
requestBodyString = bodyByteString.utf8()
request.newBuilder()
.body(ByteStringHttpBody(contentType = requestBody.contentType, bodyByteString))
.build()
}
val requestSize = requestBodyString?.toByteArray(StandardCharsets.UTF_8)?.size?.toLong()
val httpResponse = chain.proceed(newRequest)
val endTime = System.nanoTime()
val durationMs = (endTime - startTime) / 1e6
val responseBody = httpResponse.body
val bodyByteString = responseBody?.readByteString()
val responseBodyString = bodyByteString?.utf8()
val responseSize = responseBodyString?.toByteArray(StandardCharsets.UTF_8)?.size?.toLong()
val responseHeadersMap = httpResponse.headers.associate { it.name to it.value }
val isImage = httpResponse.headers.firstOrNull { it.name.equals("Content-Type", ignoreCase = true) }?.value?.startsWith("image/") == true
val floconRequest = FloconGrpcRequest(
url = request.url,
method = when (request.method) {
HttpMethod.Get -> "GET"
HttpMethod.Post -> "POST"
},
startTime = requestedAt,
durationMs = durationMs,
requestHeaders = requestHeadersMap,
requestBody = requestBodyString,
requestSize = requestSize,
responseHttpCode = httpResponse.statusCode,
responseContentType = httpResponse.headers.firstOrNull { it.name.equals("Content-Type", ignoreCase = true) }?.value,
responseBody = responseBodyString.takeUnless { isImage },
responseHeaders = responseHeadersMap,
responseSize = responseSize,
)
val json = floconRequest.toJson()
(floconClient ?: Flocon.client)?.send(
plugin = Protocol.FromDevice.GraphQl.Plugin,
method = Protocol.FromDevice.GraphQl.Method.LogNetworkCall,
body = json.toString(),
)
return if (responseBody == null || bodyByteString == null) {
httpResponse
} else {
@Suppress("DEPRECATION")
HttpResponse.Builder(statusCode = httpResponse.statusCode)
.body(bodyByteString)
.addHeaders(httpResponse.headers)
.build()
}
}
}

View file

@ -1,41 +0,0 @@
package io.github.openflocon.flocon.okhttp.model
import org.json.JSONObject
data class FloconGrpcRequest(
val url: String,
val method: String,
val startTime: Long,
val durationMs: Double,
// request
val requestHeaders: Map<String, String>,
val requestBody: String?,
val requestSize: Long?,
// response
val responseHttpCode: Int,
val responseContentType: String?,
val responseBody: String?,
val responseSize: Long?,
val responseHeaders: Map<String, String>,
) {
fun toJson(): JSONObject {
val json = JSONObject()
json.put("url", url)
json.put("method", method)
json.put("startTime", startTime)
json.put("durationMs", durationMs)
requestBody?.let { json.put("requestBody", it) }
json.put("requestHeaders", JSONObject(requestHeaders))
json.put("requestSize", requestSize)
json.put("responseHttpCode", responseHttpCode)
responseContentType?.let { json.put("responseContentType", it) }
responseBody?.let { json.put("responseBody", it) }
json.put("responseHeaders", JSONObject(responseHeaders))
json.put("responseSize", responseSize)
return json
}
}

View file

@ -18,4 +18,3 @@ include(":app")
include(":core")
include(":okhttp-interceptor")
include(":grpc-interceptor")
include(":graphql-interceptor")