-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check type name conflicts in SelectionSet (#3009)
- Loading branch information
1 parent
c4600ff
commit 415f7fe
Showing
10 changed files
with
546 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Foundation | ||
|
||
extension GraphQLType { | ||
|
||
var isListType: Bool { | ||
switch self { | ||
case .list: return true | ||
case let .nonNull(innerType): return innerType.isListType | ||
case .entity, .enum, .inputObject, .scalar: return false | ||
} | ||
} | ||
|
||
} | ||
|
||
extension IR.EntityField { | ||
|
||
/// Takes the associated ``IR.EntityField`` and formats it into a selection set name | ||
func formattedSelectionSetName( | ||
with pluralizer: Pluralizer | ||
) -> String { | ||
IR.Entity.FieldPathComponent(name: responseKey, type: type) | ||
.formattedSelectionSetName(with: pluralizer) | ||
} | ||
|
||
} | ||
|
||
extension IR.Entity.FieldPathComponent { | ||
|
||
/// Takes the associated ``IR.Entity.FieldPathComponent`` and formats it into a selection set name | ||
func formattedSelectionSetName( | ||
with pluralizer: Pluralizer | ||
) -> String { | ||
var fieldName = name.firstUppercased | ||
if type.isListType { | ||
fieldName = pluralizer.singularize(fieldName) | ||
} | ||
return fieldName.asSelectionSetName | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.