Skip to content
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

Spring server not bootstrapping correctly when following instructions in documentation/examples #1679

Closed
GV94 opened this issue Feb 21, 2023 · 7 comments
Labels
type: bug Something isn't working

Comments

@GV94
Copy link

GV94 commented Feb 21, 2023

Library Version

  • 6.3.6
  • 7.0.0-alpha.3

Describe the bug
When setting up a spring server, by referring to the docs and examples below, the server does not bootstrap correctly. Navigating to http://localhost:8080/graphiql (or any other url) results in a 404. However, when downgrading dependencies (java version, spring, graphql-kotlin-spring-server) to match what is used in this article, it works.

To Reproduce
Please refer to this reproduction repository. The main branch contains the non-working example, and there is a PR to the main branch demonstrating the working example with downgraded dependencies.

Expected behavior
The server should bootstrap correctly and serve the graphiql user interface at localhost:8080/graphiql

Edit: updated endpoint from /playground to /graphiql

@GV94 GV94 added the type: bug Something isn't working label Feb 21, 2023
@samuelAndalon
Copy link
Contributor

samuelAndalon commented Feb 21, 2023

Hello, graphql-playground is now in deprecation process and is disabled by default, this change was introduced in
#1623

and if you want to keep using playground you will have to explicitly enable it like this

graphql:
  playground:
    enabled: true

graphql playground was deprecated in favor of graphiql, which is the official IDE under graphql foundation and is available in the /graphiql endpoint.

You can refer to the prerelease docs
https://opensource.expediagroup.com/graphql-kotlin/docs/7.x.x/server/spring-server/spring-properties.

the documentation you are providing actually mentions it

Note: /playground - Prisma Labs GraphQL Playground IDE endpoint is still available, but need to be configured through the Spring Properties

@GV94
Copy link
Author

GV94 commented Feb 21, 2023

Hi,

Is /graphiql supposed to be enabled by default? In the repro it can't be accessed either (no endpoint mentioned in https://opensource.expediagroup.com/graphql-kotlin/docs/7.x.x/server/spring-server/spring-overview#default-routes can be accessed).

@GV94
Copy link
Author

GV94 commented Feb 21, 2023

and just to add:

graphql:
  playground:
    enabled: true

does not work in the repro either

@samuelAndalon
Copy link
Contributor

ok, i took a closer look at your repro repo, and there are a couple of things wrong:

  1. you are using spring-boot 3.0.2 which is not compatible with graphql-kotlin-spring-server (as it uses 2.7.2)
  2. also you need to match the graphql-java version that the graphql-kotlin version is using, as the spring bom will attempt to pull the version of graphql-java that is specified there. in this case we use graphql-java 19.2
  3. kotlin version should be 1.6.21

if you want to use spring boot 3, you can try the 7.x.x alpha releases.

@samuelAndalon
Copy link
Contributor

after fixing your dependencies im able to run the server
image

@samuelAndalon
Copy link
Contributor

plugins {
	id("org.springframework.boot") version "2.7.2"
	kotlin("jvm") version "1.6.21"
	kotlin("plugin.spring") version "1.6.21"
}

group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
	mavenCentral()
}

dependencies {
	implementation("org.springframework.boot:spring-boot-starter-webflux")
	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
	implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
	implementation("org.jetbrains.kotlin:kotlin-reflect")
	implementation("org.jetbrains.kotlin:kotlin-stdlib")
	implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
	implementation("com.expediagroup:graphql-kotlin-spring-server:6.3.6")
	implementation("com.graphql-java:graphql-java:19.2")
	testImplementation("org.springframework.boot:spring-boot-starter-test")
	testImplementation("io.projectreactor:reactor-test")
}

tasks.withType<KotlinCompile> {
	kotlinOptions {
		freeCompilerArgs = listOf("-Xjsr305=strict")
		jvmTarget = "1.8"
	}
}

tasks.withType<Test> {
	useJUnitPlatform()
}

@GV94
Copy link
Author

GV94 commented Feb 21, 2023

Ah, I see. I can indeed get it to work with spring boot 3 and java 17 by using pre-relase version 7.0.0-alpha.3. I never tried that in combination with /graphiql. Thanks a lot for clearing that out for me.

This dependency configuration works fine

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
	id("org.springframework.boot") version "3.0.2"
	id("io.spring.dependency-management") version "1.1.0"
	kotlin("jvm") version "1.7.22"
	kotlin("plugin.spring") version "1.7.22"
}

group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
	mavenCentral()
}

dependencies {
	implementation("org.springframework.boot:spring-boot-starter-ebflux")
	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
	implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
	implementation("org.jetbrains.kotlin:kotlin-reflect")
	implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
	implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
	implementation("com.expediagroup:graphql-kotlin-spring-server:7.0.0-alpha.3")
	testImplementation("org.springframework.boot:spring-boot-starter-test")
	testImplementation("io.projectreactor:reactor-test")
}

tasks.withType<KotlinCompile> {
	kotlinOptions {
		freeCompilerArgs = listOf("-Xjsr305=strict")
		jvmTarget = "17"
	}
}

tasks.withType<Test> {
	useJUnitPlatform()
}

@GV94 GV94 closed this as completed Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

No branches or pull requests

2 participants