In a typescript project I'm using graphql-tag loader in webpack to load some files from external query files - like this:
import * as queries from './queries.gql';
and the queries.gql file has a query like the following:
query get_project_rel_data get_project_related_data($id: ID!) { project(id : $id) { id key name createdDate modifiedDate products { id key name parts { id key name rendererType blocks { id key name rendererType placeholderName elements { key id content name author rendererType placeholderName } } } } } }
which gives the error
./src/modules/graphql/queries.gql
GraphQLError: Syntax Error: Expected {, found Name "get_project_related_data"
If I remove the get_project_rel_data then I get the tsx module not found error:
Type error: Cannot find module './queries.gql'. TS2307
4 | import {DocumentNode} from 'graphql';
5 | import gql from 'graphql-tag';
> 6 | import * as queries from './queries.gql';
but if I remove that offending query completely then the other queries in the file work well.
if I wrap it in { I get the expected Name found $ error discussed here https://github.com/apollographql/graphql-tag/issues/180