39 lines
976 B
TypeScript
39 lines
976 B
TypeScript
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" });
|
|
|
|
const useIntrospection = ["1", "true"].includes(
|
|
process.env.GRAPHQL_USE_INTROSPECTION?.toLowerCase() ?? ""
|
|
);
|
|
|
|
const config: CodegenConfig = {
|
|
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}`
|
|
}
|
|
}
|
|
},
|
|
|
|
documents: ["src/**/*.ts", "src/**/*.tsx"],
|
|
generates: {
|
|
"./src/__generated__/": {
|
|
preset: "client",
|
|
presetConfig: {
|
|
gqlTagName: "gql"
|
|
}
|
|
},
|
|
"introspection.json": {
|
|
plugins: ["introspection"]
|
|
}
|
|
},
|
|
ignoreNoDocuments: true
|
|
};
|
|
|
|
export default config;
|