File tree Expand file tree Collapse file tree
Sources/GraphQLGeneratorCore/Generator
Tests/GraphQLGeneratorTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ package struct SchemaGenerator {
1515 import GraphQLGeneratorRuntime
1616
1717 /// Build a GraphQL schema with the provided resolvers
18- public func buildGraphQLSchema<Resolvers: ResolversProtocol>(resolvers: Resolvers.Type) throws -> GraphQLSchema {
18+ public func buildGraphQLSchema<Resolvers: ResolversProtocol>(
19+ resolvers: Resolvers.Type,
20+ decoder: MapDecoder = .init(),
21+ ) throws -> GraphQLSchema {
1922 """
2023
2124 // Ignore any internal types (which have prefix "__")
@@ -713,7 +716,7 @@ package struct SchemaGenerator {
713716 let safeArgName = nameGenerator. swiftMemberName ( for: argName)
714717 let swiftType = try swiftTypeReference ( for: arg. type, nameGenerator: nameGenerator)
715718 // Extract value from Map based on type
716- var decodeStatement = " try MapDecoder() .decode(( \( swiftType) ).self, from: args[ \" \( argName) \" ]) "
719+ var decodeStatement = " try decoder .decode(( \( swiftType) ).self, from: args[ \" \( argName) \" ]) "
717720 if !( arg. type is GraphQLNonNull ) {
718721 // If the arg is nullable, we get errors if we try to decode an `undefined` map. This protects against that.
719722 decodeStatement = " args[ \" \( argName) \" ] != .undefined ? \( decodeStatement) : nil "
Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ struct SchemaGeneratorTests {
4343 import GraphQLGeneratorRuntime
4444
4545 /// Build a GraphQL schema with the provided resolvers
46- public func buildGraphQLSchema<Resolvers: ResolversProtocol>(resolvers: Resolvers.Type) throws -> GraphQLSchema {
46+ public func buildGraphQLSchema<Resolvers: ResolversProtocol>(
47+ resolvers: Resolvers.Type,
48+ decoder: MapDecoder = .init(),
49+ ) throws -> GraphQLSchema {
4750 let bar = try GraphQLObjectType(
4851 name: "Bar",
4952 description: """
You can’t perform that action at this time.
0 commit comments