0

I'm trying to migrate a project over to using DGS but I'm running into problems with the API gateway.

I have a Spring/DGS service running on http://localhost:3000, so the graphql queries are going to http://localhost:3000/graphql.

My API gateway has a route config:

@Bean
fun routes(builder: RouteLocatorBuilder): RouteLocator{
  return builder.routes()
    .route{it.path("/v1/users/**").uri("http://localhost:3000")}
    .route{it.path("/userService/graphql").uri("http://localhost:3000/graphql)}
    .build()
}

When I use actuator to check the routes I get:

{
    "predicate": "Paths: [/userService/graphql], match trailing slash: true",
    "route_id": "ecacf5ee-9544-485b-8a4e-4c2d02b94b8d",
    "filters": [],
    "uri": "http://localhost:3000/graphql",
    "order": 0
}

And when I go to http://localhost:3000/graphiql I can using the graphiql UI to run queries on my user service. If I send graphql queries to http://localhost:3000/graphql I get a response, but if I send the same query to http://localhost:8080/userService/graphql I get a 404. Further, if I try to hit the REST endpoints on localhost:3000 using the gateway like localhost:8080/v1/users/user/{userId} I get the expected response.

jwsinner
  • 358
  • 3
  • 9

1 Answers1

0

Try giving each route an id.

@Bean
fun routes(builder: RouteLocatorBuilder): RouteLocator{
  return builder.routes()
    .route("users") {it.path("/v1/users/**").uri("http://localhost:3000")}
    .route("graphql") {it.path("/userService/graphql").uri("http://localhost:3000/graphql)}
    .build()
}
gmrm
  • 93
  • 6