0.1.4 • Published 4 years ago

babel-plugin-apollo-helper v0.1.4

Weekly downloads
7
License
MIT
Repository
-
Last release
4 years ago

English | 简体中文

Build Status codecov NPM version NPM downloads

install

npm i -D babel-plugin-apollo-helper
// or
yarn add -D babel-plugin-apollo-helper

then .babelrc:

{
  plugins: [
    "babel-plugin-apollo-helper",
    {
      packages: Array<{specifier: string, source: string}>,
      include: Regex[],
      exclude: Regex[]
    }
  ]
}

config.packages default is :

packages: [
  { specifier: 'graphql', source: '@apollo/react-hoc' },
  { specifier: 'compose', source: 'lodash/flowRight' }
];

you can overide your custom graphql and compose

usage

input:

import { graphql } from '@apollo/react-hoc';

export default props => {
  return (
    <div>
      <span>1</span>
    </div>
  );
};

export const query = gql`
  query queryDemo {
    a {
      b
    }
  }
`;

output:

import { graphql } from '@apollo/react-hoc';
export default graphql(
  gql`
    query queryDemo {
      a {
        b
      }
    }
  `,
  {
    name: 'query'
  }
)(props => {
  return (
    <div>
      <span>1</span>
    </div>
  );
});

more usages can see feature

with babel-plugin-macros

install

.babelrc

{
  plugins: ['babel-plugin-macros']
}

usage

anything be wrapped by autoInjectGql will be injected graphql queries which is exported in current js.

import { graphql } from '@apollo/react-hoc';
import autoInjectGql from 'babel-plugin-apollo-helper/macro';

export default autoInjectGql(props => {
  return (
    <div>
      <span>1</span>
    </div>
  );
});

export const query = gql`
  query queryDemo {
    a {
      b
    }
  }
`;
0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4-alpha.5

4 years ago

0.0.5

4 years ago

0.0.4-alpha.2

4 years ago

0.0.4-alpha.3

4 years ago

0.0.4-alpha.4

4 years ago

0.0.4-alpha.1

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago