diff --git a/angel_graphql/example/main.dart b/angel_graphql/example/main.dart index 84452d8a..4ff9916f 100644 --- a/angel_graphql/example/main.dart +++ b/angel_graphql/example/main.dart @@ -57,6 +57,7 @@ main() async { class Todo extends Model { String text; + @GraphQLDocumentation(deprecationReason: 'Booleans are just *sooo* 2015!') bool completed; Todo({this.text, this.completed}); diff --git a/graphql_schema/lib/src/schema.dart b/graphql_schema/lib/src/schema.dart index 4d817268..6eeb5e3f 100644 --- a/graphql_schema/lib/src/schema.dart +++ b/graphql_schema/lib/src/schema.dart @@ -101,6 +101,7 @@ class GraphExceptionErrorLocation { /// A metadata annotation used to provide documentation to `package:graphql_server`. class GraphQLDocumentation { final String description; + final String deprecationReason; - const GraphQLDocumentation({this.description}); + const GraphQLDocumentation({this.description, this.deprecationReason}); } diff --git a/graphql_server/lib/mirrors.dart b/graphql_server/lib/mirrors.dart index 2e7da125..362eb221 100644 --- a/graphql_server/lib/mirrors.dart +++ b/graphql_server/lib/mirrors.dart @@ -163,8 +163,10 @@ String _getDeprecationReason(List metadata) { if (expires == deprecated.expires) { return 'Expires after $expires'; } else { - deprecated.expires; + return deprecated.expires; } + } else if (obj.reflectee is GraphQLDocumentation) { + return (obj.reflectee as GraphQLDocumentation).deprecationReason; } }