@@ -20,7 +20,7 @@ import {
2020import config from './config' ;
2121import { GraphqlApiClient , Logger } from './util' ;
2222import { getLaunchHubUrl } from './util/common-utility' ;
23- import { ConfigType , LogFn , Providers } from './types' ;
23+ import { ConfigType , LogFn , Providers , GraphqlHeaders } from './types' ;
2424
2525export type Flags < T extends typeof Command > = Interfaces . InferredFlags < ( typeof BaseCommand ) [ 'baseFlags' ] & T [ 'flags' ] > ;
2626export type Args < T extends typeof Command > = Interfaces . InferredArgs < T [ 'args' ] > ;
@@ -198,20 +198,27 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
198198 * @memberof BaseCommand
199199 */
200200 async prepareApiClients ( ) : Promise < void > {
201+ let headers : GraphqlHeaders = {
202+ 'X-CS-CLI' : this . context . analyticsInfo
203+ }
204+
205+ const { uid, organizationUid } = this . sharedConfig . currentConfig ;
206+
207+ if ( uid ) {
208+ headers [ 'x-project-uid' ] = uid ;
209+ }
210+
211+ if ( organizationUid ) {
212+ headers [ 'organization_uid' ] = organizationUid ;
213+ }
214+
201215 this . apolloClient = await new GraphqlApiClient ( {
202- headers : {
203- 'X-CS-CLI' : this . context . analyticsInfo ,
204- 'x-project-uid' : this . sharedConfig . currentConfig . uid ,
205- organization_uid : this . sharedConfig . currentConfig . organizationUid ,
206- } ,
216+ headers,
207217 baseUrl : this . sharedConfig . manageApiBaseUrl ,
208218 } ) . apolloClient ;
219+
209220 this . apolloLogsClient = await new GraphqlApiClient ( {
210- headers : {
211- 'X-CS-CLI' : this . context . analyticsInfo ,
212- 'x-project-uid' : this . sharedConfig . currentConfig . uid ,
213- organization_uid : this . sharedConfig . currentConfig . organizationUid ,
214- } ,
221+ headers,
215222 baseUrl : this . sharedConfig . logsApiBaseUrl ,
216223 } ) . apolloClient ;
217224 }
0 commit comments