Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NormalizedCacheObject is never used #95

Closed
sargreal opened this issue Feb 6, 2021 · 1 comment · Fixed by #96
Closed

NormalizedCacheObject is never used #95

sargreal opened this issue Feb 6, 2021 · 1 comment · Fixed by #96

Comments

@sargreal
Copy link

sargreal commented Feb 6, 2021

Expected behavior

Generated file should not trigger errors with typescript compilation

Actual behavior

When generating the queries with typescript config strict and noUnusedLocals compilation fails because the import NormalizedCacheObject is never used.

Failed to compile.

./generated/queries.tsx:10:1
Type error: 'NormalizedCacheObject' is declared but its value is never read.

   8 | import type React from 'react'
   9 | import { getApolloClient } from 'lib/with-apollo'
> 10 | import type { NormalizedCacheObject } from '@apollo/client'
     | ^
  11 | export async function getServerPageArticle(
  12 |   options: Omit<Apollo.QueryOptions<Types.ArticleQueryVariables>, 'query'>,
  13 |   ctx?: any
error Command failed with exit code 1.

Am I missing something in my configuration that would use NormalizedCacheObject?

Context

codegen.yml

overwrite: true
schema: '<redacted>'
documents: 'lib/api/**/*.graphql'
generates:
  generated/types.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-react-apollo
  generated/apollo-helpers.ts:
    plugins:
      - typescript-apollo-client-helpers
  generated/queries.tsx:
    config:
      documentMode: external
      importDocumentNodeExternallyFrom: ./types
      reactApolloVersion: 3
      withHooks: true
      withHOC: true
      apolloClientInstanceImport: 'lib/with-apollo'
    preset: import-types
    presetConfig:
      typesPath: ./types
    plugins:
      - graphql-codegen-apollo-next-ssr
hooks:
  afterOneFileWrite:
    - prettier --write
    - tslint --fix
@correttojs
Copy link
Owner

thank you for the feedback, I updated the code accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants