eddeee888 / graphql-code-generator-plugins

List of GraphQL Code Generator plugins that complements the official plugins.
MIT License
52 stars 13 forks source link

How to override the ID scalar? #333

Closed Colt45s closed 2 weeks ago

Colt45s commented 2 months ago

I am trying to implement an ID scalar according to the GraphQL Global Object Identification Specification.

codegen.ts

import { defineConfig } from "@eddeee888/gcg-typescript-resolver-files";
import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
  schema: "internal/schema/**/*.graphql",
  generates: {
    "internal/schema": defineConfig({
      scalarsOverrides: {
        ID: {
          resolver: "base/resolvers/ID#IDResolver",
        },
      },
    }),
  },
};

export default config;

base/resolvers/ID.ts

export const IDResolver = {};

No resolver is generated in resolvers.generated.ts.

eddeee888 commented 1 month ago

Hi @Colt45s ,

It looks like you can't override default scalars like ID at runtime: https://github.com/graphql/graphql-js/issues/917 Since it cannot be done at that level, I don't think we can support it at codegen level 🙂

Unless you are able to override the default scalar somehow?

eddeee888 commented 2 weeks ago

Closing this as overriding default scalar is not currently supported at GraphQL level. Thanks for reaching out!