Skip to content

Commit

Permalink
Merge pull request #584 from 99designs/fix-deprecated-directive
Browse files Browse the repository at this point in the history
Fix for @deprecated directive not appearing
  • Loading branch information
Mathew Byrne authored Mar 6, 2019
2 parents 1968a7b + 5ba8c8e commit dcd208d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
9 changes: 8 additions & 1 deletion codegen/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ func BuildData(cfg *config.Config) (*Data, error) {
return nil, err
}

dataDirectives := make(map[string]*Directive)
for name, d := range b.Directives {
if !d.Builtin {
dataDirectives[name] = d
}
}

s := Data{
Config: cfg,
Directives: b.Directives,
Directives: dataDirectives,
Schema: b.Schema,
SchemaStr: b.SchemaStr,
Interfaces: map[string]*Interface{},
Expand Down
14 changes: 9 additions & 5 deletions codegen/directive.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
)

type Directive struct {
Name string
Args []*FieldArgument
Name string
Args []*FieldArgument
Builtin bool
}

func (b *builder) buildDirectives() (map[string]*Directive, error) {
Expand All @@ -22,8 +23,10 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
if _, ok := directives[name]; ok {
return nil, errors.Errorf("directive with name %s already exists", name)
}

var builtin bool
if name == "skip" || name == "include" || name == "deprecated" {
continue
builtin = true
}

var args []*FieldArgument
Expand All @@ -50,8 +53,9 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
}

directives[name] = &Directive{
Name: name,
Args: args,
Name: name,
Args: args,
Builtin: builtin,
}
}

Expand Down
50 changes: 50 additions & 0 deletions codegen/testserver/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions codegen/testserver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) {
func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) {
panic("not implemented")
}
func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) {
panic("not implemented")
}
func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) {
panic("not implemented")
}
Expand Down
1 change: 1 addition & 0 deletions codegen/testserver/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Query {
inputSlice(arg: [String!]!): Boolean!
shapeUnion: ShapeUnion!
autobind: Autobind
deprecatedField: String! @deprecated(reason: "test deprecated directive")
}

type Subscription {
Expand Down
4 changes: 4 additions & 0 deletions codegen/testserver/stub.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dcd208d

Please sign in to comment.