Typings for multiple graphql query imports via graphql-tag/loader

Viewed 298

I have a component which imports a query from a graphql file via the graphql-tag/loader of webpack.

query testQuery {
  test
}

query test2Query {
   test
}
import { testQuery, test2Query } from './test.graphql'

I'm now trying to declare a general typing for all possible queries and mutations:

declare module '*.graphql' {
  import { DocumentNode } from 'graphql';
  const exp: { [key: string]: DocumentNode };

  export default exp;
}

The typescript compiler doesn't recognize my import. I know my typing definition is faulty, though I can't seem to find documentation which would help me in this case.

Any suggestions?

0 Answers
Related