Max RozenMax Rozen

How do you make relay-compiler run automatically?

Making relay-compiler run automatically

Relay can be annoying to work with as relay-compiler needs to run every time you change your GraphQL schema, or your resolvers.

With relay-compiler-webpack-plugin that’s no longer the case - webpack can run it for you!

Here’s how you use it:

const RelayCompilerWebpackPlugin = require('relay-compiler-webpack-plugin');
// rest of your config
new RelayCompilerWebpackPlugin({
    schema: 'schema.graphql',
    src: 'src/',
    extensions: ['js', 'jsx', 'ts', 'tsx'],
    artifactDirectory: 'src/__generated__',

Do you struggle to keep up with best practices in React?

I send a single email weekly with an article like this one to help improve the quality of your React apps. Lots of developers like them, and I'd love to hear what you think as well. You can always unsubscribe.

    Join 158 React developers who signed up last month!


    © 2020 Max Rozen. All rights reserved.