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__',
}),

(Shameless plug for the useEffect book I wrote below)

Tired of infinite re-renders when using useEffect?

A few years ago when I worked at Atlassian, a useEffect bug I wrote took down part of Jira for roughly one hour.

Knowing thousands of customers can't work because of a bug you wrote is a terrible feeling. To save others from making the same mistakes, I wrote a single resource that answers all of your questions about useEffect, after teaching it here on my blog for the last couple of years. It's packed with examples to get you confident writing and refactoring your useEffect code.

In a single afternoon, you'll learn how to fetch data with useEffect, how to use the dependency array, even how to prevent infinite re-renders with useCallback.

Master useEffect, in a single afternoon.

useEffect By Example's book cover