Closed tusharmath closed 1 month ago
The current behavior seem to be correct ?!
Current config
schema
@server(port: 8000)
@upstream(baseURL: "http://localhost:3000", httpCache: 42, batch: {delay: 100}) {
query: Query
}
type Query {
searchUser(input: UserSearch): [User]!
@http(
method: POST
path: "/users/search"
body: "{{.args.input}}"
)
}
input UserSearch {
emailAddress: String! @modify(name: "email_address")
}
type User {
id: Int!
name: String!
email: String!
}
The generated client schema for UserSearch from the playground :
input UserSeach {
email_address: String!
}
Ok, let me try to make it more clear 🙏 Keep in mind that the issue I'm seeing is that I want to have consistency in the casing of my schema. Having mixed snake case and camel case because of the underlying resolvers is not ideal IMO.
First, @modify
doesn't seem to be allowed on inputs:
But it does kinda work.
emailAddress: String! @modify(name: "email_address")
Example schema:
schema @server(port: 8000) @upstream(baseURL: "http://localhost:8008") {
query: Query
}
type Query {
searchUser(input: UserSearch): [User]!
@http(method: POST, path: "/users/search", body: "{{.args.input}}")
}
input UserSearch {
emailAddress: String! @modify(name: "email_address")
}
type User {
id: Int!
name: String!
email: String!
}
Example query:
query test {
searchUser(input: {email_address: "test@test"}) {
id
}
}
Running nc -l 8008
you'll see:
POST /users/search HTTP/1.1
content-type: application/json
accept: */*
user-agent: Tailcall/1.0
host: localhost:8008
content-length: 29
{"email_address":"test@test"}
Issue: the email_address
is forced to be snake case in the exposed schema, which breaks consistency. There is no point in using @modify
here since the resulting schema is snake case, we could just have:
input UserSearch {
email_address: String!
}
Which is also snake case :/
email_address: String! @modify(name: "emailAddress")
Schema:
schema @server(port: 8000) @upstream(baseURL: "http://localhost:8008") {
query: Query
}
type Query {
searchUser(input: UserSearch): [User]!
@http(method: POST, path: "/users/search", body: "{{.args.input}}")
}
input UserSearch {
email_address: String! @modify(name: "emailAddress")
}
type User {
id: Int!
name: String!
email: String!
}
Query:
query test {
searchUser(input: {emailAddress: "test@test"}) {
id
}
}
Payload:
POST /users/search HTTP/1.1
content-type: application/json
accept: */*
user-agent: Tailcall/1.0
host: localhost:8008
content-length: 28
{"emailAddress":"test@test"}
Here is the issue is the opposite, we do have emailAddress
in the exposed schema, but it's emailAddress
that is serialized, not email_address
.
alright thank you for clarification makes sense now
Action required: Issue inactive for 30 days. Status update or closure in 7 days.
Status update: It is awaiting code review
Action required: Issue inactive for 30 days. Status update or closure in 7 days.
Issue closed after 7 days of inactivity.
Context Discussion - https://github.com/tailcallhq/tailcall/discussions/2476
The @modify only works on output types. We need to support
@modify
on input types as wellProposal
The generated client schema should look like:
Internally Tailcall should handle these field name conversions efficiently.
Technical Requirements