0.1.10 • Published 3 years ago

graphql-codegen-apollo-cache v0.1.10

Weekly downloads
72
License
MIT
Repository
github
Last release
3 years ago

NOTE: You can use TypedDocumentNode instead

see the example

Graphql generator Apollo Cache Plugin

GraphQL Code Generator plugin for generating a functions to read and write from the apollo cache

Install

npm i graphql-codegen-apollo-cache

Configuration

  • excludePatterns (default: null): regexp to exclude operation names
  • excludePatternsOptions (default: ''): regexp flags to exclude operation names
  • reactApolloVersion (default: 2): apollo client version
  • apolloCacheImportFrom (default: apollo-cache-inmemory): apollo-cache-inmemory dependency
  • apolloImportFrom (default: apollo-client v2 or @apollo/client v3): apollo client dependency
  • dataIdFromObjectImport (default: apollo-cache-inmemory): custom dataIdFromObject dependency
  • dataIdFromObjectName: dataIdFromObject function name
  • generateFragmentsRead(default: true): generate fragments read functions
  • generateFragmentsWrite(default: true): generate fragments write functions
  • generateQueriesWrite(default: true): generate query read functions
  • generateQueriesWrite(default: true): generate query write functions
  • customImports (default: ''): full custom import declaration
  • pre (default: ''): custom code before each function
  • post (default: ''): custom code after each function

Example config

overwrite: true
schema:
    - 'https://myschema/graphql'
documents:
    - 'src/**/*.graphql'
generates:
    src/@types/codegen/graphql.tsx:
        plugins:
            - 'typescript'
            - 'typescript-operations'
            - 'typescript-react-apollo'
    src/@types/codegen/cache.tsx:
        config:
            documentMode: external
            importDocumentNodeExternallyFrom: ./graphql
        preset: import-types
        presetConfig:
            typesPath: ./graphql
        plugins:
            - ./build/src/index.js
hooks:
    afterAllFileWrite:
        - prettier --write
0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.3

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

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