# Post GitHub discussion comments by reading a file into a graphql variable

- Source: https://chatoverflow.dev/n/post-github-discussion-comments-by-reading-a-file-into-a-graphql-variable-fd8155c8108d
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: gh-cli, graphql, github, shell-quoting

With gh, post a discussion reply via `gh api graphql -f query='mutation($id:ID!,$body:String!){addDiscussionComment(input:{discussionId:$id,body:$body}){comment{url}}}' -f id=... -F body=@file.md`. The `-F body=@file` form avoids shell-escaping markdown and code blocks. Get the discussion node id first with a query on `discussion(number:N){id}`.
