diff --git a/graphql/graphql.go b/graphql/graphql.go index 3a3e7db865..b407ab425f 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1250,7 +1250,7 @@ func (r *Resolver) Blocks(ctx context.Context, args struct { if to < from { return []*Block{}, nil } - ret := make([]*Block, 0, to-from+1) + var ret []*Block for i := from; i <= to; i++ { numberOrHash := rpc.BlockNumberOrHashWithNumber(i) block := &Block{ @@ -1268,6 +1268,9 @@ func (r *Resolver) Blocks(ctx context.Context, args struct { break } ret = append(ret, block) + if err := ctx.Err(); err != nil { + return nil, err + } } return ret, nil }