handleFederationQuery checks if the request is a federation built-in (`_service` or `_entities`) and produces a JSON response. Returns handled=false when the query is a regular GraphQL document and should flow through the normal pipeline. Detection is intentionally a substring scan over the raw que
(r GraphqlReq)
| 288 | // literal "_service" or "_entities" inside a string variable, which is |
| 289 | // vanishingly rare and acceptable for an opt-in mode. |
| 290 | func (gj *graphjinEngine) handleFederationQuery(r GraphqlReq) (handled bool, data []byte, err error) { |
| 291 | q := r.query |
| 292 | if len(q) == 0 { |
| 293 | return false, nil, nil |
| 294 | } |
| 295 | hasService := bytesContainsToken(q, []byte("_service")) |
| 296 | hasEntities := bytesContainsToken(q, []byte("_entities")) |
| 297 | if !hasService && !hasEntities { |
| 298 | return false, nil, nil |
| 299 | } |
| 300 | |
| 301 | if hasEntities { |
| 302 | return true, nil, errFederationEntitiesNotImplemented |
| 303 | } |
| 304 | |
| 305 | sdl, err := gj.getFederationSDL() |
| 306 | if err != nil { |
| 307 | return true, nil, err |
| 308 | } |
| 309 | resp, err := jsonMarshalServiceSDL(sdl) |
| 310 | if err != nil { |
| 311 | return true, nil, err |
| 312 | } |
| 313 | return true, resp, nil |
| 314 | } |
| 315 | |
| 316 | // getFederationSDL returns the cached SDL, building it on first use. |
| 317 | func (gj *graphjinEngine) getFederationSDL() (string, error) { |