A Laravel Mix extension for GraphQL support for Webpack.
yarn add -D @pp-spaces/laravel-mix-graphql
or
npm install @pp-spaces/laravel-mix-graphql --save-dev
In your webpack.mix.js
, import @pp-spaces/laravel-mix-graphql
:
// webpack.mix.js
const mix = require("laravel-mix");
/**
* Import laravel-mix-graphql
*/
require("@pp-spaces/laravel-mix-graphql");
/**
* Register loader
*/
mix
.js("resources/js/app.js", "public/js")
.sass("resources/sass/app.scss", "public/css")
.graphql();
Done!, re-run your compile command.
Within your project, e.g. app.js
, you can import .graphql
or .gql
schema directly.
// app.js
import UserQuery from "./graphql/UserQuery.graphql";
Socheat, Web Developer