11import GraphQL
2+ import Runtime
23
34public protocol InputType : MapInitializable { }
45public protocol OutputType : MapFallibleRepresentable { }
@@ -45,10 +46,12 @@ public class FieldBuilder<Root, Context, Type> {
4546 /// - Parameter excluding: properties excluded from the export
4647 /// - Throws: Reflection Errors
4748 public func exportFields( excluding: String ... ) throws {
48- for property in try properties ( Type . self) {
49- if !excluding. contains ( property. key) {
50- let field = GraphQLField ( type: try schema. getOutputType ( from: property. type, field: property. key) )
51- fields [ property. key] = field
49+ let info = try typeInfo ( of: Type . self)
50+
51+ for property in info. properties {
52+ if !excluding. contains ( property. name) {
53+ let field = GraphQLField ( type: try schema. getOutputType ( from: property. type, field: property. name) )
54+ fields [ property. name] = field
5255 }
5356 }
5457 }
@@ -65,11 +68,11 @@ public class FieldBuilder<Root, Context, Type> {
6568 if let resolve = resolve {
6669 r = { source, _, context, info in
6770 guard let s = source as? Type else {
68- throw GraphQLError ( message: " Expected source type \( Type . self) but got \( type ( of: source) ) " )
71+ throw GraphQLError ( message: " Expected source type \( Type . self) but got \( Swift . type ( of: source) ) " )
6972 }
7073
7174 guard let c = context as? Context else {
72- throw GraphQLError ( message: " Expected context type \( Context . self) but got \( type ( of: context) ) " )
75+ throw GraphQLError ( message: " Expected context type \( Context . self) but got \( Swift . type ( of: context) ) " )
7376 }
7477
7578 guard let output = try resolve ( s, NoArguments ( ) , c, info) else {
@@ -103,11 +106,11 @@ public class FieldBuilder<Root, Context, Type> {
103106 if let resolve = resolve {
104107 r = { source, _, context, info in
105108 guard let s = source as? Type else {
106- throw GraphQLError ( message: " Expected source type \( Type . self) but got \( type ( of: source) ) " )
109+ throw GraphQLError ( message: " Expected source type \( Type . self) but got \( Swift . type ( of: source) ) " )
107110 }
108111
109112 guard let c = context as? Context else {
110- throw GraphQLError ( message: " Expected context type \( Context . self) but got \( type ( of: context) ) " )
113+ throw GraphQLError ( message: " Expected context type \( Context . self) but got \( Swift . type ( of: context) ) " )
111114 }
112115
113116 return try resolve ( s, NoArguments ( ) , c, info)
@@ -137,11 +140,11 @@ public class FieldBuilder<Root, Context, Type> {
137140 if let resolve = resolve {
138141 r = { source, _, context, info in
139142 guard let s = source as? Type else {
140- throw GraphQLError ( message: " Expected source type \( Type . self) but got \( type ( of: source) ) " )
143+ throw GraphQLError ( message: " Expected source type \( Type . self) but got \( Swift . type ( of: source) ) " )
141144 }
142145
143146 guard let c = context as? Context else {
144- throw GraphQLError ( message: " Expected context type \( Context . self) but got \( type ( of: context) ) " )
147+ throw GraphQLError ( message: " Expected context type \( Context . self) but got \( Swift . type ( of: context) ) " )
145148 }
146149
147150 return try resolve ( s, NoArguments ( ) , c, info)
@@ -186,11 +189,11 @@ public class FieldBuilder<Root, Context, Type> {
186189 if let resolve = resolve {
187190 r = { source, _, context, info in
188191 guard let s = source as? Type else {
189- throw GraphQLError ( message: " Expected source type \( Type . self) but got \( type ( of: source) ) " )
192+ throw GraphQLError ( message: " Expected source type \( Type . self) but got \( Swift . type ( of: source) ) " )
190193 }
191194
192195 guard let c = context as? Context else {
193- throw GraphQLError ( message: " Expected context type \( Context . self) but got \( type ( of: context) ) " )
196+ throw GraphQLError ( message: " Expected context type \( Context . self) but got \( Swift . type ( of: context) ) " )
194197 }
195198
196199 return try resolve ( s, NoArguments ( ) , c, info)
@@ -225,13 +228,13 @@ public class FieldBuilder<Root, Context, Type> {
225228 resolve: resolve. map { resolve in
226229 return { source, args, context, info in
227230 guard let s = source as? Type else {
228- throw GraphQLError ( message: " Expected source type \( Type . self) but got \( type ( of: source) ) " )
231+ throw GraphQLError ( message: " Expected source type \( Type . self) but got \( Swift . type ( of: source) ) " )
229232 }
230233
231234 let a = try A ( map: args)
232235
233236 guard let c = context as? Context else {
234- throw GraphQLError ( message: " Expected context type \( Context . self) but got \( type ( of: context) ) " )
237+ throw GraphQLError ( message: " Expected context type \( Context . self) but got \( Swift . type ( of: context) ) " )
235238 }
236239
237240 guard let output = try resolve ( s, a, c, info) else {
@@ -263,13 +266,13 @@ public class FieldBuilder<Root, Context, Type> {
263266 resolve: resolve. map { resolve in
264267 return { source, args, context, info in
265268 guard let s = source as? Type else {
266- throw GraphQLError ( message: " Expected type \( Type . self) but got \( type ( of: source) ) " )
269+ throw GraphQLError ( message: " Expected type \( Type . self) but got \( Swift . type ( of: source) ) " )
267270 }
268271
269272 let a = try A ( map: args)
270273
271274 guard let c = context as? Context else {
272- throw GraphQLError ( message: " Expected context type \( Context . self) but got \( type ( of: context) ) " )
275+ throw GraphQLError ( message: " Expected context type \( Context . self) but got \( Swift . type ( of: context) ) " )
273276 }
274277
275278 return try resolve ( s, a, c, info)
0 commit comments