Socket
Socket
Sign inDemoInstall

graphql-codegen-apollo-cache

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-codegen-apollo-cache

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


Version published
Weekly downloads
47
increased by95.83%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 02 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc