Skip to content

Commit

Permalink
Add native support for Set by converting resolve type to Array.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulofaria committed Jun 28, 2020
1 parent 6a95768 commit b3b155a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/Graphiti/FieldsInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ public final class FieldsInitializer<ObjectType, Keys : RawRepresentable, Contex
return FieldInitializer(field)
}

// Adds native support for Set by converting resolve type to Array.
@discardableResult
public func field<ResolveType>(
_ name: Keys,
at keyPath: KeyPath<ObjectType, Set<ResolveType>>
) -> FieldInitializer<ObjectType, Keys, Context, NoArguments> {
let field = Field<ObjectType, Keys, Context, NoArguments, Set<ResolveType>, Array<ResolveType>>(name: name.rawValue) { (type: ObjectType) in
return { (context: Context, arguments: NoArguments) in
return Array(type[keyPath: keyPath])
}
}

fields.append(field)
return FieldInitializer(field)
}

@discardableResult
public func field<FieldType, ResolveType>(
_ name: Keys,
Expand Down

0 comments on commit b3b155a

Please sign in to comment.