{"record":{"id":"2eec8fac82890b34","repo":"github/github-mcp-server","slug":"failed-to-get-graphql-url-w-2eec8f","errorCode":null,"errorMessage":"failed to get GraphQL URL: %w","messagePattern":"failed to get GraphQL URL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/dependencies.go","lineNumber":361,"sourceCode":"\t}\n\ttoken := tokenInfo.Token\n\n\t// Construct GraphQL client\n\t// We use NewEnterpriseClient unconditionally since we already parsed the API host\n\t// Wrap transport with GraphQLFeaturesTransport to inject feature flags from context,\n\t// matching the transport chain used by the remote server.\n\tgqlHTTPClient := &http.Client{\n\t\tTransport: &transport.BearerAuthTransport{\n\t\t\tTransport: &transport.GraphQLFeaturesTransport{\n\t\t\t\tTransport: http.DefaultTransport,\n\t\t\t},\n\t\t\tToken: token,\n\t\t},\n\t}\n\n\tgraphqlURL, err := d.apiHosts.GraphqlURL(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get GraphQL URL: %w\", err)\n\t}\n\n\tgqlClient := githubv4.NewEnterpriseClient(graphqlURL.String(), gqlHTTPClient)\n\treturn gqlClient, nil\n}\n\n// GetRawClient implements ToolDependencies.\nfunc (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error) {\n\tclient, err := d.GetClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trawURL, err := d.apiHosts.RawURL(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get Raw URL: %w\", err)\n\t}\n","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/dependencies.go#L343-L379","documentation":"GetGQLClient resolves the GraphQL endpoint through the injected utils.APIHostResolver; a resolver error becomes this wrap and no githubv4 client can be built. The bundled utils.APIHost computes gqlURL (https://api.github.com/graphql for dotcom, https://api.<host>/graphql for GHEC/GHES) at construction and never fails on lookup, so this error indicts a custom resolver or a misconfigured RequestDeps rather than GitHub itself.","triggerScenarios":"deps.GetGQLClient(ctx) with a custom APIHostResolver whose GraphqlURL(ctx) errors; resolvers for environments that do not expose GraphQL (some GHES configs have GraphQL disabled and an integrator may model that as an error); per-tenant resolvers failing to map a tenant to a host. Standard NewAPIHost wiring cannot produce it at request time.","commonSituations":"Internal gateways fronting GitHub where only REST is proxied; test fakes stubbing GraphqlURL with errors; partial implementations of the five-method APIHostResolver interface after adding a new deployment type.","solutions":["If GraphQL is genuinely unavailable in your environment, disable the GraphQL-dependent toolsets (discussions) rather than letting every call fail","Make GraphqlURL return a pre-parsed absolute URL derived from the base host (api.<host>/graphql) and fail only at construction","Preflight GraphqlURL at startup alongside the other resolver methods","Read the wrapped message to distinguish resolver bugs from environment problems"],"exampleFix":"// before\nfunc (r fake) GraphqlURL(ctx context.Context) (*url.URL, error) {\n\treturn nil, errors.New(\"not implemented\") // every GraphQL tool dies\n}\n\n// after\ntype r struct{ gql *url.URL }\nfunc newR(base *url.URL) *r {\n\treturn &r{gql: base.JoinPath(\"/graphql\")} // https://api.example.com -> .../graphql\n}\nfunc (x r) GraphqlURL(context.Context) (*url.URL, error) { return x.gql, nil }","handlingStrategy":"validation","validationCode":"// startup check for the GraphQL endpoint\ngql, err := apiHosts.GraphqlURL(context.Background())\nif err != nil || gql == nil || !gql.IsAbs() {\n\tlog.Fatalf(\"GraphQL URL unusable: %v\", err)\n}","typeGuard":"func supportsGraphQL(a utils.APIHostResolver) bool {\n\tu, err := a.GraphqlURL(context.Background())\n\treturn err == nil && u != nil && u.IsAbs()\n}","tryCatchPattern":null,"preventionTips":["Compute the GraphQL URL once from the base host (api.<host>/graphql)","If your environment lacks GraphQL, disable the discussions toolset rather than erroring per call","Preflight resolver methods at init alongside REST/uploads/raw"],"tags":["go","configuration","graphql","dependency-injection"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}