apollo.macro

a babel macros plugin, auto inject grahql query with apollo hoc

Usage no npm install needed!

<script type="module">
  import apolloMacro from 'https://cdn.skypack.dev/apollo.macro';
</script>

README

preval.macro

NPM version NPM downloads

This is a babel-plugin-macros plugin.

just make babel-plugin-apollo-helper easier to use.

usage

input:

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

export default autoInjectGql(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 babel-plugin-apollo-helper's test