Giter Site home page Giter Site logo

Comments (7)

Oxymoron290 avatar Oxymoron290 commented on July 30, 2024 2

I'm sorry, I got confused
Found what I needed here - https://github.com/jeggy/ktorgraphql/blob/master/src/GraphQLRequest.kt

from kgraphql.

jeggy avatar jeggy commented on July 30, 2024

how are you calling .execute() ?

Passing variables is split into 2 different arguments.

Here's an example:

val dollarSign = '$'

val query = """
    query(${dollarSign}id: Int! = 6){
        TruckLoad(id: ${dollarSign}id) {
            id
            TruckLoad{
                id
            }
        }
    }""".trimIndent()
val variables = """
    {
        "id": 5
    }
""".trimIndent()

val res = schema.execute(query, variables)

println(res)

from kgraphql.

Oxymoron290 avatar Oxymoron290 commented on July 30, 2024

Using ktor:

routing {
    route("/graphql") {
        post {
            val request = call.receive<GraphQLRequest>()
            val query = request.query
            val context: ThetaContext by inject()
            val sch = ThetaSchema(context)
            val result = sch.schema.execute(query)
            call.respondText(result, io.ktor.http.ContentType.Application.Json)
        }
    }
}

from kgraphql.

jeggy avatar jeggy commented on July 30, 2024

I'm planning to do a module for ktor, so in the feature you would just install KGraphQL into ktor something like this:

embeddedServer(...) {
    install(KGraphQL)
}

But for for you could take a look at this project: https://github.com/jeggy/ktorgraphql/blob/master/src/Application.kt#L55

from kgraphql.

Oxymoron290 avatar Oxymoron290 commented on July 30, 2024

I think I saw a PR or something about that in ktor's project. do you have a link?

from kgraphql.

jeggy avatar jeggy commented on July 30, 2024

I've seen some that are using the java implementation of GraphQL. But I haven't seen any for KGraphQL.
I'm gonna do one that is specifically made for KGraphQL

from kgraphql.

Oxymoron290 avatar Oxymoron290 commented on July 30, 2024

Awesome. also, trying your solution it shows that request does not have properties for mutation or variables
image

Using v0.6.6

from kgraphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.