gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

Ways to modify a result of a more high-level resolver

Open asp3cto opened this issue 1 year ago • 0 comments

I have something like this in my schema

type Query {
  request: QueryMessageOt!
}

type QueryMessageOt {
  requestID: ID!

  offline: Boolean!

  executionTime: Float

  cargo(filter: CargoFilterIt!, cursor: String, limit: Int): CargoResult
}

How can i modify root fields in my cargo resolver? For example, i want to accumulate the execution time, but when i do this:

func (r *queryMessageOtResolver) Cargo(ctx context.Context, obj *model.QueryMessageOt, filter model.CargoFilterIt, cursor *string, limit *int) (*model.CargoResult, error) {
    *obj.ExecutionTime += 777.0
    return nil, nil
}

i still get old execution time from request resolver.

asp3cto avatar Apr 03 '25 18:04 asp3cto