string interpolation results in query type never #421
-
Describe the bugI'm quite new to this library/GraphQL, so it could well be I'm doing something wrong. to repro:
When I try to move my existing query, the type of import { graphql } from "./graphql";
const query = graphql(`
query paginate($cursor: String, $organization: String!, $repo: String!) {
repository(owner: $organization, name: $repo) {
issues(
first: 100
after: $cursor
orderBy: { field: UPDATED_AT, direction: ASC }
filterBy: { since: ${since ? `"${since.toISOString()}"` : "null"} }
) {
nodes {
id
number
title
body
url
state
stateReason
createdAt
updatedAt
closedAt
author {
login
url
}
labels(first: 10) {
nodes {
id
name
color
description
}
}
comments(first: 100, orderBy: { field: UPDATED_AT, direction: ASC }) {
nodes {
id
author {
login
url
}
body
createdAt
updatedAt
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
`); I could well be doing something wrong — I am actually just trying to get syntax highlighting + typing when I write the query and I want to pass the query string back in to GitHub's Octokit. Thanks for the help! ReproductionNo response gql.tada version"gql.tada": "^1.8.10", Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Converted to a discussion since this seems more like a question. Have you made sure that the editor setup is complete and GraphQLSP is running and giving you editor feedback, e.g. diagnostics?
|
Beta Was this translation helpful? Give feedback.
-
You can't interpolate values, you should use document variables. Making the template literal dynamic won't work with TypeScript. https://graphql.org/learn/queries/#variables |
Beta Was this translation helpful? Give feedback.
You can't interpolate values, you should use document variables. Making the template literal dynamic won't work with TypeScript. https://graphql.org/learn/queries/#variables