tailcallhq / tailcall

High Performance GraphQL Runtime
https://tailcall.run
Apache License 2.0
1.28k stars 253 forks source link

Unclear error message for using ` batchkey` without enabling batching #2029

Closed amitksingh1490 closed 3 months ago

amitksingh1490 commented 4 months ago

The error message for enabling batching in upstream is not very clear if someone specifies the batchKey in the @http but forgets to enable batching in the @upstream directive.

Steps to Reproduce

Use this config and start the server

schema
@server(port: 8000)
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) {
  query: Query
}

type Query {
  posts: [Post] @http(path: "/posts")
}

type User {
  id: Int!
  name: String!
  username: String!
  email: String!
  phone: String
  website: String
}

type Post {
  id: Int!
  userId: Int!
  title: String!
  body: String!
  user: User @http(path: "/users", query: [{key: "id", value: "{{.value.userId}}"}], batchKey: ["id"])
}

Actual

 INFO File read: ./examples/jsonplaceholder_batch.graphql ... ok
 INFO N + 1 detected: 0
ERROR Invalid Configuration
Caused by:
  • GroupBy can only be applied if batching is enabled [at Post.user.@http]

Expected

 INFO File read: ./examples/jsonplaceholder_batch.graphql ... ok
 INFO N + 1 detected: 0
ERROR Invalid Configuration
Caused by:
  • "batchKey" can only be applied if batching is enabled in upstream [at Post.user.@http]
bnchi commented 4 months ago

@amitksingh1490 just wondering is it a simple text change here https://github.com/tailcallhq/tailcall/blob/e6d8e3885537213f749ca8edac288ef10b165afe/src/core/blueprint/operators/http.rs#L20 or is there a specific conditions that needs to be met for this to get triggered ?

amitksingh1490 commented 4 months ago

Just a text change now that you pointed out the code, there is another message Valid::<(), String>::fail("GroupBy is only supported for GET requests".to_string()) Where we have wrong message here also

github-actions[bot] commented 3 months ago

Action required: Issue inactive for 30 days. Status update or closure in 7 days.

github-actions[bot] commented 3 months ago

Issue closed after 7 days of inactivity.