tailcall
tailcall copied to clipboard
bug: improve path variable detection logic in config generator.
Present Behaviour
Currently, the path variable detection logic is simplistic. It checks if the URL has a number between forward slashes, which works correctly in the following scenarios:
For URL /api/v1/users/12
and /api/v1/users/12/comments
is correctly converted to
@http(path: "/api/v1/users/{{.args.p1}}")
@http(path: "/api/v1/users/{{.args.p1}}/comments")
However, the logic fails in the following scenarios where the path variable is a string or contains non-numeric/mixed characters:
For URL /v1/albums/4a
and URL /v1/albums/wpa
it is incorrectly converted to
album(p1: Int!): Album @http(path: "/v1/albums/{{.args.p1}}a")
album(p1: Int!): Album @http(path: "/v1/albums/wpa")
Expected Behaviour
The path variable detection logic should be enhanced to detect path variables in all scenarios, including numbers, strings, or mixed characters, and generate a valid @http directive:
For URL /v1/albums/4a
and /v1/albums/wpa
, it should be converted to
album(p1: String!): Album @http(path: "/v1/albums/{{.args.p1}}").
album(p1: String!): Album @http(path: "/v1/albums/{{.args.p1}}").
Technical Requirements:
- update the path variable detection logic to handle cases like above.
- update the test cases if necessary.
- add integration test that cover's this case.