Skip to content

Commit

Permalink
Only return Fields, Types for Services with Schema
Browse files Browse the repository at this point in the history
Unreachable services haven't loaded a schema yet so the definition is
nil, causing the meta plugins query to fail with a nil dereference
panic.

Co-Authored-By: Nicolas Maquet <nicolas@movio.co>
  • Loading branch information
pkqk and Nicolas Maquet committed May 4, 2023
1 parent a2b73b4 commit 067f3d5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ func (r *metaResolver) GetType(ctx context.Context, args struct{ ID graphql.ID }
}

func (r *metaResolver) getTypes(schema *ast.Schema) []brambleType {
if schema == nil {
return nil
}
var result []brambleType
for _, def := range schema.Types {
result = append(result, r.brambleType(def.Name, def))
Expand Down Expand Up @@ -322,6 +325,9 @@ func (r *metaResolver) GetField(ctx context.Context, args struct{ ID graphql.ID
}

func (r *metaResolver) getFields(schema *ast.Schema) []brambleField {
if schema == nil {
return nil
}
var result []brambleField
for _, def := range schema.Types {
for _, f := range def.Fields {
Expand Down

0 comments on commit 067f3d5

Please sign in to comment.