Skip to content

Commit

Permalink
SchemaBuilder.ToJSON instead of SchemaToJSON (fixes #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed Nov 26, 2016
1 parent fff173b commit 33cd194
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ func (b *SchemaBuilder) ApplyResolver(resolver interface{}) (*Schema, error) {
}, nil
}

func (b *SchemaBuilder) ToJSON() ([]byte, error) {
result, err := exec.IntrospectSchema(b.schema)
if err != nil {
return nil, err
}
return json.Marshal(result)
}

type Schema struct {
schema *schema.Schema
exec *exec.Exec
Expand Down Expand Up @@ -125,20 +133,6 @@ func (s *Schema) Exec(ctx context.Context, queryString string, operationName str
}
}

func SchemaToJSON(schemaString string) ([]byte, error) {
b := New()
if err := b.Parse(schemaString); err != nil {
return nil, err
}

result, err := exec.IntrospectSchema(b.schema)
if err != nil {
return nil, err
}

return json.Marshal(result)
}

type ScalarConfig struct {
ReflectType reflect.Type
CoerceInput func(input interface{}) (interface{}, error)
Expand Down

0 comments on commit 33cd194

Please sign in to comment.