Skip to content

add ktor server plugin module #1667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 9, 2023
Merged

Conversation

dariuszkuc
Copy link
Collaborator

@dariuszkuc dariuszkuc commented Feb 5, 2023

📝 Description

Creates Ktor GraphQL Plugin with similar functionality as the existing SpringBoot auto-configuration module.

fun Application.graphQLModule() {
    install(GraphQL) {
        schema {
            packages = listOf("com.example")
            queries = listOf(HelloWorldQuery())
        }
    }
}

🔗 Related Issues

Resolves: #1471

@dariuszkuc dariuszkuc added type: enhancement New feature or request changes: minor Changes require a minor version labels Feb 5, 2023
/**
* Configuration properties that define supported GraphQL configuration options.
*/
class GraphQLConfiguration(config: ApplicationConfig)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with the same configuration properties as used by Spring. This config contains some properties that can be set through configuration files (i.e. same as spring) and others that can only be set programmatically.

I'm not a big fan of how this is all structured at the moment so most likely structure of this file will change.

In general there are 3 areas of configuration:

  • schema - everything related to schema generation (e.g. which queries to include)
  • engine - everything related to GraphQL Java engine configuration
  • server - Ktor server custom config (e.g. context factory)

I'm thinking I will move the existing properties (which were matching spring config) under those three sections, e.g. when configuring schema I think it would make sense to specify target packages in the same place

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One drawback of reorganizing the properties would be the change in property file mapping - currently properties match the path from the root graphql prefix, e.g. graphql.packages is a top level packages property. If we move those around then we either have to use different properties than in Spring (not ideal but I guess it should be fine?) or have a mismatch between paths and variables, e.g.

  • graphql.packages would become graphql.schema.packages
  • graphql.introspection.enabled would become graphql.engine.introspection.enabled

@dariuszkuc dariuszkuc marked this pull request as ready for review February 7, 2023 02:09
@dariuszkuc dariuszkuc changed the title [draft] add ktor server plugin module add ktor server plugin module Feb 7, 2023
@dariuszkuc dariuszkuc enabled auto-merge (squash) February 7, 2023 21:35
@dariuszkuc dariuszkuc disabled auto-merge February 7, 2023 23:34
@dariuszkuc dariuszkuc enabled auto-merge (squash) February 7, 2023 23:34
@dariuszkuc dariuszkuc merged commit 2ab428a into ExpediaGroup:master Feb 9, 2023
@dariuszkuc dariuszkuc deleted the ktor-plugin branch February 9, 2023 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: minor Changes require a minor version type: enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

Create a ktor-plugin for easy setup
3 participants