Skip to content

Commit

Permalink
Add enum type extension to infer cases via CaseIterable from an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsteinerde committed Feb 21, 2020
1 parent 7c03ecb commit 986e46f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/GraphQLKit/Graphiti+Enum.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Graphiti
import Vapor

extension Enum where EnumType: CaseIterable {
// Initialize an enum type from a `CaseIterable` enum.
public convenience init(
_ type: EnumType.Type,
name: String? = nil
) {
self.init(type, name: name, EnumType.allCases.map({ Value($0) }))
}
}

0 comments on commit 986e46f

Please sign in to comment.