Skip to content

Document how to import graphql files (typed-query-document) #1047

@fregante

Description

@fregante

Maybe the solution is hidden behind #1046, but so far I'm not seeing any types with the suggested tsconfig:

		"plugins": [
			{
				"name": "ts-graphql-plugin",
				"schema": "https://docs.github.com/public/schema.docs.graphql",
				"typegen": {
					"addons": [
						"ts-graphql-plugin/addons/typed-query-document"
					]
				}
			}
		]
import listPrsForFileQuery from './list-prs-for-file.gql';
// ^ Error: Cannot find module './list-prs-for-file.gql' or its corresponding type declarations.ts(2307)

Until now I had a simple string type export in my globals.d.ts:

declare module '*.gql' {
	export = string;
}

but I suppose I should let the typed query document take over instead, so I removed that declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions