Skip to content

.headers cannot be evaluated successfully in .graphql #3381

@victor-develop

Description

@victor-develop

Prerequisites

  • I have checked the existing issues to ensure this is not a duplicate.
  • I am running the latest version of Tailcall.

Describe the bug

I tried to follow docs example referencing " {{.headers.x-user-id}} "" and found it never get evaluated successfully.
When hyphen is involved in the header key, it just doesn't evaluate.
When is a a-z header key, it evaluates to empty.

Note: I already added allowedHeaders in @upstream directive.

Steps to reproduce

  1. tailcall init hello && cd hello
  2. Replace the main.graphql content as below
schema @server @upstream(allowedHeaders: ["aaa", "x-user-id"]) {
  query: Query
}

type Query {
  greet: String! @expr(body: "Hello, World!")
  debugHeader(name: String!): String @expr(body: "{{.headers.{{.args.name}}}}")
  aaa: String @expr(body: "{{.headers.aaa}}")
  xUserId: String @expr(body: "{{.headers.x-user-id}}")
}

Then tailall start ./main.json

  1. Now try to make a graphQL request as below

HTTP headers:
{
"aaa": "my-aaa-value",
"x-user-id": "my-user-id"
}

Query

{
    greet
    debugHeader(name: "aaa")
    aaa
    xUserId
}


Expected behavior

{
    "data": {
        "greet": "Hello, World!",
        "debugHeader": "my-aaa-value",
        "aaa": "my-aaa-value",
        "xUserId": "my-user-id"
    }
}

Actual behavior

Received response:

{
    "data": {
        "greet": "Hello, World!",
        "debugHeader": "{{.headers.{{.args.name}}}}",
        "aaa": "",
        "xUserId": "{{.headers.x-user-id}}"
    }
}

Screenshots

N/A

Environment information:

  • Operating System: (MacOS 15.4.1 (24E263))
  • Tailcall Version: (v1.6.8)
  • GraphQL Client/version : I tried both the playgound and Postman, same result.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions