· coding · 3 min read
Who Uses This GraphQL Field?
Before changing a GraphQL field, find the client code that requests it and the server code that supplies it.
Say you’re about to rename a GraphQL field called trades. Which client requests would break, and which server function should you read before changing it? A search for trades can turn up types, tests, and unrelated uses. The request itself might be called OpenTrades, and the function that supplies the field might live in a different repository.
I use Mori, a tool that indexes source code into a local graph, to narrow down which files to read. In this example it connects a TypeScript function that sends a request, the field path declared by the GraphQL schema, and the Go resolver, the method that supplies the field’s value.

Three Places to Look Before Changing the Field
| Where to Look | What to Check |
|---|---|
Client file trades.ts | Function openTrades sends the query named OpenTrades. |
Schema file schema.graphqls | The query asks for trades under the root field perp, giving the path Query.perp.trades. |
Server file schema.resolvers.go | Go method Trades supplies the value for that field. |
These are the places I’d review together before changing the field. The example below shows how to recover that trail from source, including the files to open.
Try It on Two Small Repositories
I ran the example with Mori 0.14.8. You can reproduce it with two directories and a few source files. Mori reads the files directly, so you can leave the server stopped. Mori setup guide
In directory client, put this in file trades.ts.
export function openTrades() {
return fetch("/graphql", {
method: "POST",
body: JSON.stringify({
query: `query OpenTrades { perp { trades { id } } }`,
}),
})
}In directory server, add the SDL file schema.graphqls.
type Query { perp: Perp! }
type Perp { trades: [Trade!]! }
type Trade { id: ID! }Add file gqlgen.yml to identify the resolver package and schema.
schema:
- schema.graphqls
resolver:
package: graph
layout: follow-schema
dir: .Finally, put the resolver method in file schema.resolvers.go.
package graph
import "context"
func (r *perpResolver) Trades(ctx context.Context, obj *Perp) ([]*Trade, error) {
return r.store.OpenTrades(ctx)
}Find the Client and Resolver in Mori
From the parent directory, index each side. Then tell Mori to link the client’s requests to fields in the server’s schema.
mori cli --quiet index_repository --repo_path "$PWD/server" --name example-server
mori cli --quiet index_repository --repo_path "$PWD/client" --name example-client
mori cli --quiet index_repository \
'{"repo_path":"./client","name":"example-client","mode":"cross-repo-intelligence","target_projects":["example-server"]}'Mori linked the request to both the outer field Query.perp and the nested field Query.perp.trades. The query below asks for the resolver of the nested field and the client code Mori recorded against it.
mori cli --quiet query_graph '{
"project": "example-server",
"query": "MATCH (h)-[:HANDLES]->(rt:Route)<-[x:CROSS_GRAPHQL_CALLS]-() WHERE h.name = \"Trades\" AND rt.qualified_name = \"__graphql__Query.perp.trades\" RETURN rt.name, h.name, h.file_path, x.callers LIMIT 10"
}'The result had one row. For Query.perp.trades, it pointed me to method Trades in file schema.resolvers.go and function openTrades in file trades.ts.
Read the Files Before You Make the Change
I open the client query to see which fields it requests, then read the resolver to see what it does. Here, method Trades calls r.store.OpenTrades. I’d read that method and the relevant tests before changing what the field returns. The graph link comes from source, so it can’t tell me which clients call it in production.
If a link is missing, check that the client query exists as source text, that the provider indexed its schema and resolver files, and that the link run used the intended provider project. Recheck the index after source changes. For the tool arguments and coverage checks, see the Mori Graph skill and Mori project page.
Unique Divine


