import type { CodegenConfig } from "@graphql-codegen/cli";

const schemaUrl = process.env.GRAPHQL_SCHEMA_URL || process.env.GRAPHQL_HTTP_ENDPOINT || "http://localhost:3000/api/graphql";

const config: CodegenConfig = {
  schema: schemaUrl,
  documents: ["graphql/operations/**/*.graphql"],
  generates: {
    "composables/graphql/generated.ts": {
      plugins: [
        "typescript",
        "typescript-operations",
        "typed-document-node",
        "typescript-vue-apollo",
      ],
      config: {
        withCompositionFunctions: true,
        vueCompositionApiImportFrom: "vue",
        dedupeFragments: true,
        namingConvention: "keep",
      },
    },
  },
  ignoreNoDocuments: false,
};

export default config;
