fix: Create a client config function that is retrieved when app is loading (#496)

* fix: Create a client config function that is retrieved when app is loaded

* update index.tsx

* fixed linter issues
This commit is contained in:
Deepak Singh
2023-07-05 03:58:59 +05:30
committed by GitHub
parent 41edcd81d8
commit 9c09da18db
9 changed files with 115 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { Args, Mutation, Resolver } from '@nestjs/graphql';
import { AuthTokens } from './dto/token.entity';
import { Args, Mutation, Resolver, Query} from '@nestjs/graphql';
import { AuthTokens, ClientConfig} from './dto/token.entity';
import { TokenService } from './services/token.service';
import { RefreshTokenInput } from './dto/refresh-token.input';
import { BadRequestException } from '@nestjs/common';
@ -61,4 +61,17 @@ export class AuthResolver {
return { tokens: tokens };
}
}
@Query(() => ClientConfig)
async clientConfig(): Promise<ClientConfig> {
const displayGoogleLogin = process.env.AUTH_GOOGLE_CLIENT_ID !== undefined;
const prefillLoginWithSeed = process.env.NODE_ENV === 'development';
const clientConfig: ClientConfig = {
display_google_login: displayGoogleLogin,
prefill_login_with_seed: prefillLoginWithSeed,
};
return Promise.resolve(clientConfig);
}
}

View File

@ -23,3 +23,12 @@ export class AuthTokens {
@Field(() => AuthTokenPair)
tokens: AuthTokenPair;
}
@ObjectType()
export class ClientConfig {
@Field(() => Boolean)
display_google_login: boolean;
@Field(() => Boolean)
prefill_login_with_seed: boolean;
}