-
-
Notifications
You must be signed in to change notification settings - Fork 34
Description
I configured graphql-let
for a small project to generate the document types for the .graphql
files. As I added the Webpack config to use graphql-let loader it breaks the hot module reload feature and every change I make to the code restarts the server making the development process suboptimal.
For reference, here is the project when I configured it https://github.com/alex-vladut/aws-amplify-cdk, and the Webpack config could be found here https://github.com/alex-vladut/aws-amplify-cdk/blob/main/apps/todo/webpack.config.js.
Another issue I encountered is that whenever I make a change to any graphql file the type file is correctly generated, but for some reason, the typescript compiler is not updated and still shows an error. If I restart the app, it picks up the types as expected and works fine. As an example, let's say I have the following file getUser.graphql
query User($id: ID!) {
getUser(id: $id) {
id
# name
}
}
It is referenced in a React component as follows:
import { useQuery } from '@apollo/client';
import { UserDocument } from './getUser.graphql';
export function UserFromLib() {
const { data, loading, error } = useQuery(UserDocument);
return <div>{data?.getUser?.name}</div>;
}
Notice that here I reference the name
field which was not defined in the query. While the app is running, even if the field is added to be returned from the Graphql query, it still shows a typescript compilation error that name is not defined. graphql-let correctly updated the type file though.
I would be curious if anyone encountered such issues in their projects and found a solution, or could point me to possible things I can do to further investigate. Thanks for your help.