Skip to content

Idea: Alternative design for integrating with ktor #190

@LSafer

Description

@LSafer

I believe graphql doesn't need a plugin. Instead, it needs a
routing extension just like the get and post extensions.

For example:

fun Route.configureGraphql() {
    route("/graphql") {
        graphqlPlayground()
        graphql {
            wrapErrors = true

            schema {
                firstSchema()
                secondSchema()
                thierdSchema()

                firstRootSchema()
                secondRootSchema()
                thierdRootSchema()
            }
        }
    }
}

This way we don't need the wrapWith: {...} and endpoint: String
and playground: Boolean arguments in the configuration object.
And gives us more flexibility and control over handling execution
exceptions.


I made a library/utility implementing this design

https://github.com/lsafer/kgraphql-ktor

In this library I implemented the described design.
Additionally, I fixed serialization issues and error
handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions