Skip to content

Commit 776ce5e

Browse files
committed
Fix uninitialized buffer pool for introspection query
1 parent 512479d commit 776ce5e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/exec/resolvable/schema.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"github.com/graph-gophers/graphql-go/ast"
88
)
99

10+
var disabledBufferPool = newBufferPool(0)
11+
1012
type Schema struct {
1113
*Meta
1214
ast.Schema
@@ -21,10 +23,19 @@ type Schema struct {
2123
}
2224

2325
func (s *Schema) BufferPool() Pool[*bytes.Buffer] {
26+
if s.bufferPool == nil {
27+
return disabledBufferPool
28+
}
29+
2430
return s.bufferPool
2531
}
2632

2733
func newSchema(astSchema *ast.Schema, resolvers map[string]interface{}, query, mutation, subscription Resolvable, maxPooledBufferCap int) *Schema {
34+
var bufferPool Pool[*bytes.Buffer]
35+
if maxPooledBufferCap > 0 {
36+
bufferPool = newBufferPool(maxPooledBufferCap)
37+
}
38+
2839
return &Schema{
2940
Meta: newMeta(astSchema),
3041
Schema: *astSchema,
@@ -35,6 +46,6 @@ func newSchema(astSchema *ast.Schema, resolvers map[string]interface{}, query, m
3546
Mutation: mutation,
3647
Subscription: subscription,
3748

38-
bufferPool: newBufferPool(maxPooledBufferCap),
49+
bufferPool: bufferPool,
3950
}
4051
}

0 commit comments

Comments
 (0)