gql-tag preset: Issue with indention
See original GitHub issueDescribe the bug
The graphql query passed to the generated gql
function is not recognized due a mismatch in the indention.
To Reproduce Steps to reproduce the behavior:
- Define a graphql query as
const checkLoggedIn = gql(/* GraphQL */ `
query CheckLoggedIn {
me {
id
}
}
`)
- Run the code generation using the
gql-tag preset
- Observe that
checkLoggedIn
has type unknown.
The problem is the indention. The generated gql file has the following signature
export function gql(source: "query CheckLoggedIn {\n me {\n id\n }\n}"): (typeof documents)["query CheckLoggedIn {\n me {\n id\n }\n}"];
but the argument has additional indention. Indeed, if I remove the fallback to unknown
in the generated gql method, then I get the following error:
Argument of type '"\n query CheckLoggedIn {\n me {\n id\n }\n }\n "' is not assignable to parameter of type '"query CheckLoggedIn {\n me {\n id\n }\n}"'
Note the additional newline at the start, and the different amount of whitespace.
- My GraphQL schema:
# Put your schema here
- My GraphQL operations:
# Put your operations here
- My
codegen.yml
config file:
documents: - 'src/**/*.ts' - '!src/gql/**/*'generates: ./src/gql/: preset: gql-tag-operations-preset
Expected behavior
Environment:
- OS:
@graphql-codegen/...
: latest- NodeJS:
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (6 by maintainers)
Top Results From Across the Web
gql-tag-operations-preset - GraphQL Code Generator
This preset generates typings for your inline gql function usages, without having to manually specify import statements for the documents.
Read more >Filter Data from Your Views - Tableau Help
On Tableau Server and Tableau Cloud, presets are applied when the view first loads in the browser, but not when the browser or...
Read more >Vue JavaScript Tutorial in Visual Studio Code
Vue JavaScript tutorial showing IntelliSense, debugging, and code navigation support in the Visual Studio Code editor.
Read more >Custom Transformation - use cases with advanced SQL queries
Merging Jira Issue tables by linked issues and keys; 18Formatting a header of Jira Issue; 19Counting the definite value in a column ...
Read more >Getting Started with Dashboards - Datadog Docs
These basic dashboards enable team discussion and speed up issue resolution. ... Browse the search results for dashboards marked Preset and see if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the exact same issue, I was able to resolve it by setting the version of
@graphql-tools/code-file-loader
to7.0.1
usingresolutions
inpackage.json
.@graphql-tools/code-file-loader@7.0.3
seems to have introduced a breaking change, causing this issueThen I think resolving this issue is as easy as adding the skipIndent config here: https://github.com/dotansimha/graphql-code-generator/blob/6734c58055d283f051bf32f115f2308000e56431/packages/graphql-codegen-cli/src/graphql-config.ts#L16