Skip to content

Latest commit

 

History

History
210 lines (133 loc) · 7.71 KB

File metadata and controls

210 lines (133 loc) · 7.71 KB

@graphiql/plugin-code-exporter

1.0.5

Patch Changes

  • Updated dependencies []:
    • @graphiql/react@0.20.4

1.0.4

Patch Changes

  • Updated dependencies [2b6ea316]:
    • @graphiql/react@0.20.3

1.0.3

Patch Changes

1.0.2

Patch Changes

  • Updated dependencies [e89c432d]:
    • @graphiql/react@0.20.2

1.0.1

Patch Changes

  • Updated dependencies [39bf31d1]:
    • @graphiql/react@0.20.1

1.0.0

Patch Changes

  • Updated dependencies [f6afd22d]:
    • @graphiql/react@0.20.0

0.3.5

Patch Changes

  • Updated dependencies []:
    • @graphiql/react@0.19.4

0.3.4

Patch Changes

  • Updated dependencies [2348641c]:
    • @graphiql/react@0.19.3

0.3.3

Patch Changes

  • Updated dependencies [d67c13f6]:
    • @graphiql/react@0.19.2

0.3.2

Patch Changes

0.3.1

Patch Changes

0.3.0

Minor Changes

  • #3330 bed5fc86 Thanks @acao! - BREAKING CHANGE: fix lifecycle issue in plugin-explorer, change implementation pattern

    value and setValue is no longer an implementation detail, and are handled internally by plugins. the plugin signature has changed slightly as well.

    now, instead of something like this:

    import { useExplorerPlugin } from '@graphiql/plugin-explorer';
    import { snippets } from './snippets';
    import { useExporterPlugin } from '@graphiql/plugin-code-exporter';
    
    const App = () => {
      const [query, setQuery] = React.useState('');
      const explorerPlugin = useExplorerPlugin({
        query,
        onEdit: setQuery,
      });
      const codeExporterPlugin = useExporterPlugin({
        query,
        snippets,
      });
    
      const plugins = React.useMemo(
        () => [explorerPlugin, codeExporterPlugin],
        [explorerPlugin, codeExporterPlugin],
      );
    
      return (
        <GraphiQL
          query={query}
          onEditQuery={setQuery}
          plugins={plugins}
          fetcher={fetcher}
        />
      );
    };

    you can just do this:

    import { explorerPlugin } from '@graphiql/plugin-explorer';
    import { snippets } from './snippets';
    import { codeExporterPlugin } from '@graphiql/plugin-code-exporter';
    import { createGraphiQLFetcher } from '@graphiql/toolkit';
    
    // only invoke these inside the component lifecycle
    // if there are dynamic values, and then use useMemo() (see below)
    const explorer = explorerPlugin();
    const exporter = codeExporterPlugin({ snippets });
    
    const fetcher = createGraphiQLFetcher({ url: '/graphql' });
    
    const App = () => {
      return <GraphiQL plugins={[explorer, exporter]} fetcher={fetcher} />;
    };

    or this, for more complex state-driven needs:

    import { useMemo } from 'react';
    import { explorerPlugin } from '@graphiql/plugin-explorer';
    import { snippets } from './snippets';
    import { codeExporterPlugin } from '@graphiql/plugin-code-exporter';
    
    const explorer = explorerPlugin();
    const fetcher = createGraphiQLFetcher({ url: '/graphql' });
    
    const App = () => {
      const { snippets } = useMyUserSuppliedState();
      const exporter = useMemo(
        () => codeExporterPlugin({ snippets }),
        [snippets],
      );
    
      return <GraphiQL plugins={[explorer, exporter]} fetcher={fetcher} />;
    };

0.2.0

Minor Changes

0.1.4

Patch Changes

  • #3292 f86e4172 Thanks @B2o5T! - fix umd build names graphiql-plugin-code-exporter.umd.js and graphiql-plugin-explorer.umd.js

0.1.3

Patch Changes

0.1.3-alpha.0

Patch Changes

0.1.2

Patch Changes

  • #3017 4a2284f5 Thanks @thomasheyenbrock! - Avoid bundling code from react/jsx-runtime so that the package can be used with Preact

  • #3063 5792aaa5 Thanks @B2o5T! - avoid useMemo with empty array [] since React can't guarantee stable reference, + lint restrict syntax for future mistakes

0.1.1

Patch Changes

0.1.0

Minor Changes