github.com/spread-ai/gqlgen@v0.0.0-20221124102857-a6c8ef538a1d/graphql/oneshot.go (about)

     1  package graphql
     2  
     3  import "context"
     4  
     5  func OneShot(resp *Response) ResponseHandler {
     6  	var oneshot bool
     7  
     8  	return func(context context.Context) *Response {
     9  		if oneshot {
    10  			return nil
    11  		}
    12  		oneshot = true
    13  
    14  		return resp
    15  	}
    16  }