Ryan Brink
06/03/2023, 11:20 AM> npx diagnose-endpoint@1.1.0 --endpoint=<http://localhost:8080>
Diagnosing <http://localhost:8080>
⚠ OPTIONS response is missing header 'access-control-allow-methods: POST'
(📫 Interested in previewing a local tunnel to bypass CORS requirements? Please let us know at <https://docs.google.com/forms/d/e/1FAIpQLScUCi3PdMerraiy6GpD-QiC_9KEKVHr4oDL5Vef5fIvzqqQWg/viewform> )
but, as far as I can tell, my ktor api should be configured properly
fun Application.myApplicationModule() {
install(CallLogging) {
level = Level.TRACE
}
install(CORS) {
allowHeader(HttpHeaders.ContentType)
anyHost()
}
routing {
route("/") {
post {
val models = getOgModels()
val sdl = generateCustomObjectGraph(models).toString()
val schema = parseSdl(sdl).validateAsSchema().value!!.toIntrospectionSchema().toJson()
call.response.header("content-type", "application/json")
call.respondText(schema)
}
}
}
}
Ktor docs indicate that by default, POST is allowed https://ktor.io/docs/cors.html#methodsmbonnin
06/03/2023, 4:32 PMnpx diagnose-endpoint
warning is a false positive, I can run the same thing locally finembonnin
06/03/2023, 4:35 PMtoJson()
will return the __Schema
field, you'll need to wrap it in the GraphQL response type (the one with "data" and "error")mbonnin
06/03/2023, 4:36 PMmbonnin
06/03/2023, 4:37 PMRyan Brink
06/03/2023, 4:45 PMmbonnin
06/03/2023, 4:49 PMRyan Brink
06/03/2023, 4:55 PM_call_.respondText("{*\"*data*\"*: *$*schema}")
but still get the error 😞 still good to at least be sending the right payload nowmbonnin
06/03/2023, 4:56 PM{
"data": {
"__schema": {
"queryType": {
"name": "Query"
},
"mutationType": {
"name": "Mutation"
},
"subscriptionType": {
"name": "Subscription"
},
"types": [
mbonnin
06/03/2023, 4:56 PMmbonnin
06/03/2023, 5:25 PMmbonnin
06/03/2023, 5:25 PM