Skip to content

Typed-Document-Node with Apollo-AngularΒ #980

@erikwrede

Description

@erikwrede

We are currently using typescript-apollo-angular to generate our type hints.
We now want to make use of typed-document-node in conjunction with ts-apollo-angular to benefit from the additional ergonomics of typed-document-node during cache interactions.

We have tried the following configuration, but the typed document node lacks all of the generic type annotations:

  documents: [
    "apps/**/src/app/**/*.graphql",
    "libs/**/*.graphql"
  ],
  generates: {
    ["./"]: {
      preset: "near-operation-file",
      presetConfig: {
        baseTypesPath: "our-base-types-module",
        importTypesNamespace: "GraphQlTypes"
      },
      config: {
        documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode",
        documentMode: "documentNode"
      },
      plugins: [
        "typescript-operations",
        "typescript-apollo-angular"
      ]
    }
  },

Describe the solution you'd like

Have either an additional option for the apollo angular plugin to use the typed document node directly, or make it compatible in a better way

Describe alternatives you've considered

The alternative is duplicating the type definitions. (One for apollo-angular, one for typed-document-node). This is not an option as it unnecessarily increases bundle size and creates type redundancies, decreasing code ergonomics.

Typed-Document-Node just by itself as a replacement for the apollo-angular plugin is also not an alternative due to the handy inject syntax that goes well with apollo-angular.

Is your feature request related to a problem? Please describe.

See above, it currently does not work.

This issue continues the discussion from dotansimha/graphql-code-generator#9500 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions