Created
October 22, 2024 12:51
-
-
Save valentin-harrang/287f2e941cda020f36e85c9961bf35d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dotenv from 'dotenv'; | |
import type { CodegenConfig } from '@graphql-codegen/cli'; | |
import { AuthService } from './auth.service'; | |
import { AUTH_CONFIG } from './auth.config'; | |
dotenv.config(); | |
const authService = new AuthService(AUTH_CONFIG); | |
const getConfig = async (): Promise<CodegenConfig> => { | |
const graphqlUrl = process.env.GRAPHQL_URL || ''; | |
const token = await authService.getToken(); | |
const config: CodegenConfig = { | |
schema: [ | |
{ | |
[graphqlUrl]: { | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: `Bearer ${token}`, | |
}, | |
}, | |
}, | |
], | |
documents: ['./src/**/*.ts'], | |
ignoreNoDocuments: true, | |
generates: { | |
'./src/integration/src/graphql/generated/': { | |
preset: 'client', | |
}, | |
'./src/integration/src/graphql/schema.graphql': | |
{ | |
plugins: ['schema-ast'], | |
config: { | |
includeDirectives: true, | |
}, | |
}, | |
}, | |
hooks: { | |
afterAllFileWrite: ['npm run format', 'npm run lint:fix || true'], | |
}, | |
}; | |
return config; | |
}; | |
export default getConfig(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment