MCPcopy Create free account
hub / github.com/desktop/desktop / fetchUserCopilotInfo

Method fetchUserCopilotInfo

app/src/lib/api.ts:2116–2158  ·  view source on GitHub ↗

* Fetches the Copilot info related to the user (license and API endpoint). * * @returns Copilot license and API endpoint.

()

Source from the content-addressed store, hash-verified

2114 * @returns Copilot license and API endpoint.
2115 */
2116 public async fetchUserCopilotInfo(): Promise<UserCopilotInfo | undefined> {
2117 // Copilot is not available on GHES
2118 if (isGHES(this.endpoint)) {
2119 return undefined
2120 }
2121
2122 const graphql = `
2123 {
2124 viewer {
2125 copilotEndpoints {
2126 api
2127 }
2128
2129 copilotLicenseType
2130 isCopilotDesktopEnabled
2131 }
2132 }
2133 `
2134
2135 try {
2136 const response = await this.ghRequest('POST', '/graphql', {
2137 body: { query: graphql },
2138 customHeaders: {
2139 'GraphQL-Features': 'copilot_iap_max_sku',
2140 },
2141 })
2142 if (response === null) {
2143 return undefined
2144 }
2145
2146 const json: ViewerCopilotResponse =
2147 (await response.json()) as ViewerCopilotResponse
2148 const { viewer } = json.data
2149 return {
2150 copilotEndpoint: viewer.copilotEndpoints.api,
2151 isCopilotDesktopEnabled: viewer.isCopilotDesktopEnabled,
2152 copilotLicenseType: viewer.copilotLicenseType,
2153 }
2154 } catch (e) {
2155 log.warn(`fetchUserCopilotInfo: failed with endpoint ${this.endpoint}`, e)
2156 return undefined
2157 }
2158 }
2159
2160 /**
2161 * Creates a push protection bypass for a repository.

Callers 1

fetchUserFunction · 0.95

Calls 3

ghRequestMethod · 0.95
isGHESFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected