All Projects → nodkz → babel-plugin-transform-relay-hot

nodkz / babel-plugin-transform-relay-hot

Licence: MIT License
🔥 BabelRelayPlugin with hot reload

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to babel-plugin-transform-relay-hot

babel-plugin-flow-relay-query
Babel plugin which converts Flow types into Relay fragments
Stars: ✭ 38 (+35.71%)
Mutual labels:  relay, babel-plugin
Magiql
🌐 💫 Simple and powerful GraphQL Client, love child of react-query ❤️ relay
Stars: ✭ 45 (+60.71%)
Mutual labels:  relay, babel-plugin
flutter dynamic
The flutter_dynamic is a library that create flutter application dynamic.
Stars: ✭ 66 (+135.71%)
Mutual labels:  hot-reload
babel-plugin-transform-html-import-to-string
Turn HTML imports (and export from) into constant strings
Stars: ✭ 22 (-21.43%)
Mutual labels:  babel-plugin
vite-plugin-relay
A vite plugin for Relay
Stars: ✭ 44 (+57.14%)
Mutual labels:  relay
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (+21.43%)
Mutual labels:  babel-plugin
babel-plugin-source-map-support
A Babel plugin which automatically makes stack traces source-map aware
Stars: ✭ 41 (+46.43%)
Mutual labels:  babel-plugin
graphql-pynamodb
Graphene PynamoDB Integration
Stars: ✭ 63 (+125%)
Mutual labels:  relay
meros
🪢 A fast utility that makes reading multipart responses simple
Stars: ✭ 109 (+289.29%)
Mutual labels:  relay
hotbuild
a cross platform hot compilation tool for golang
Stars: ✭ 181 (+546.43%)
Mutual labels:  hot-reload
babel-plugin-transform-replace-expressions
A Babel plugin for replacing expressions with other expressions
Stars: ✭ 23 (-17.86%)
Mutual labels:  babel-plugin
relay-compiler-plus
Custom relay compiler which supports persisted queries
Stars: ✭ 68 (+142.86%)
Mutual labels:  relay
babel-plugin-transform-stitches-display-name
www.npmjs.com/package/babel-plugin-transform-stitches-display-name
Stars: ✭ 12 (-57.14%)
Mutual labels:  babel-plugin
esbuild-plugin-relay
An esbuild plugin to transform tagged GraphQL template literals for Relay.
Stars: ✭ 14 (-50%)
Mutual labels:  relay
postfix-relay
Postfix SMTP relay docker image
Stars: ✭ 76 (+171.43%)
Mutual labels:  relay
babel-plugin-display-name-custom
display name inference for your custom react component creators
Stars: ✭ 15 (-46.43%)
Mutual labels:  babel-plugin
Lith
WeeChat relay client
Stars: ✭ 32 (+14.29%)
Mutual labels:  relay
react16-seed-with-apollo-graphql-scss-router4-ssr-tests-eslint-prettier-docker-webpack3-hot
Seed to create your own project using React with Apollo GraphQL client
Stars: ✭ 19 (-32.14%)
Mutual labels:  hot-reload
AzuraRelay
A "relay in a box" containing a lightweight web application and Icecast servers that can connect to and relay an AzuraCast parent instance.
Stars: ✭ 20 (-28.57%)
Mutual labels:  relay
babel-plugin-remove-test-ids
🐠 Babel plugin to strip `data-test-id` HTML attributes
Stars: ✭ 40 (+42.86%)
Mutual labels:  babel-plugin

babel-plugin-transform-relay-hot

NPM version npm

Babel plugin for transforming graphql literals and Relay.QL tagged templates (when "compat": true). It uses json/graphql file with GraphQL schema. This plugin wraps babel-plugin-relay. Each time the schema file changes, the wrapper updates instance of babel-plugin-relay with new schema without completely restarting dev server.

Install

yarn add babel-plugin-transform-relay-hot --dev

or

npm install babel-plugin-transform-relay-hot --save-dev

Usage with .babelrc

{
  "plugins": [
    ["transform-relay-hot", {
      "schema": "./build/schema.graphql",
      "watchInterval": 2000,
      "verbose": true
    }],
  ]
}

Options

  • schema
    • Required
    • Type: String
    • Path to graphql schema json/graphql file
  • watchInterval
    • Type: Number
    • Default: 2000
    • Time interval in milliseconds to check mtime of json file. Internally used setTimeout().unref() cause fs.watch blocks babel from exit.
    • You may disable watching by setting watchInterval: 0.
  • verbose
    • Type: Boolean
    • Default: false
    • Log to console when schema reloaded.
  • Also you may define additional options from babel-plugin-relay

Use "compat": true option for Relay Classic.

How to generate schema.graphql or schema.graphql.json files

You may use webpack-plugin-graphql-schema-hot or do it manually:

import fs from 'fs';
import path from 'path';
import { printSchema } from 'graphql';
import Schema from './schema';

export default function generateSchema() {
  fs.writeFileSync(
    path.join(__dirname, './build/schema.graphql'),
    printSchema(schema)
  );
}
import fs from 'fs';
import path from 'path';
import { graphql, introspectionQuery } from 'graphql';
import Schema from './schema';

export default async function generateSchemaJson() {
  const result = await (graphql(Schema, introspectionQuery));
  fs.writeFileSync(
    path.join(__dirname, './build/schema.graphql.json'),
    JSON.stringify(result, null, 2)
  );
}

Recommended modules

🔥 webpack-plugin-graphql-schema-hot

Webpack plugin which tracks changes in your GraphQL Schema files and generates schema introspection in json and txt formats. webpack-plugin-graphql-schema-hot can freeze Webpack, while this plugin catch changes from json file. For this you need set waitOnStart and waitOnRebuild options (in Webpack plugin) equal to watchInterval (from this babel plugin):

import path from 'path';
import WebpackPluginGraphqlSchemaHot from 'webpack-plugin-graphql-schema-hot';

const config = {
  // ...
  plugins: [
    new WebpackPluginGraphqlSchemaHot({
      schemaPath: path.resolve(__dirname, '../schema/index.js'),
      output: {
        json: path.resolve(__dirname, '../build/schema.graphql.json'),
        txt: path.resolve(__dirname, '../build/schema.graphql'),
      },
      runOnStart: true,
      waitOnStart: 2000, // <----- value from `watchInterval`
      waitOnRebuild: 2000, // <----- value from `watchInterval`
      verbose: true,
    }),
  ]
}

🔥 eslint-plugin-graphql

For eslint checks of Relay.QL tagged templates you may use eslint-plugin-graphql. It also tracks changes of graphql schema json file with following config:

// In a file called .eslintrc.js
const path = require('path');

module.exports = {
  parser: "babel-eslint",
  rules: {
    "graphql/template-strings": ['error', {
      env: 'relay',
      schemaJsonFilepath: path.resolve(__dirname, './build/schema.graphql.json'),
    }]
  },
  plugins: [
    'graphql'
  ]
}

🔥 js-graphql-intellij-plugin

GraphQL language support for IntelliJ IDEA and WebStorm, including Relay.QL tagged templates in JavaScript and TypeScript.

🔥 webpack-plugin-relay-touch-dependents

Trigger webpack rebuilds after your GraphQL Schema has been updated and saved to JSON..

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].