DEV Community

Discussion on: Processing .graphql extension in the Typescript compilation process.

Collapse
 
piglovesyou profile image
Soichi Takamura

Hi, I caught up finally. Not sure but is seems you're running it with ts-node so that's why? You need webpack with graphql-let/loader properly cofigured.

Collapse
 
hellozeze profile image
UncleZeze πŸ‡ΏπŸ‡¦

Hi, the application is a nextjs web app with Typescript. This is the webpack config section in the next.config.js:

webpack: (config, options) => {

            config.resolve.alias["components"] = path.join(__dirname, "components");
            config.resolve.alias["lib"] = path.join(__dirname, "lib");
            config.resolve.alias["public"] = path.join(__dirname, "public");
            config.resolve.alias["server"] = path.join(__dirname, "server");
            config.module.rules.push({
                test: /\.graphql$/,
                exclude: /node_modules/,
                use: [options.defaultLoaders.babel, { loader: "graphql-let/loader" }],
            });
            config.module.rules.push({
                test: /\.graphqls$/,
                exclude: /node_modules/,
                use: ["graphql-tag/loader", "graphql-let/schema/loader"],
            });
            return config;
        }