gluestick/codegen.ts

39 lines
976 B
TypeScript
Raw Normal View History

2023-04-25 14:33:16 -04:00
import { CodegenConfig } from "@graphql-codegen/cli";
// graphql-codegen doesn't load .env.local, so we have to do it manually
import * as dotenv from "dotenv";
dotenv.config({ path: ".env.local" });
2023-04-28 21:19:06 -04:00
const useIntrospection = ["1", "true"].includes(
process.env.GRAPHQL_USE_INTROSPECTION?.toLowerCase() ?? ""
);
2023-04-25 14:33:16 -04:00
const config: CodegenConfig = {
2023-04-28 21:19:06 -04:00
schema: useIntrospection
? "introspection.json"
: {
[`http://${process.env.LDAP_HOST}:17170/api/graphql`]: {
headers: {
// can't make the request automatically (await on top level)
Authorization: `Bearer ${process.env.GRAPHQL_CODEGEN_AUTH}`
}
}
},
2023-04-25 14:33:16 -04:00
documents: ["src/**/*.ts", "src/**/*.tsx"],
generates: {
"./src/__generated__/": {
preset: "client",
presetConfig: {
gqlTagName: "gql"
}
2023-04-28 21:19:06 -04:00
},
"introspection.json": {
plugins: ["introspection"]
2023-04-25 14:33:16 -04:00
}
},
ignoreNoDocuments: true
};
export default config;