This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly print list scalar input types (closes #93)
- Loading branch information
1 parent
cabefd0
commit b16deb9
Showing
4 changed files
with
33 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
GraphQLInputType, | ||
GraphQLScalarType, | ||
GraphQLEnumType, | ||
GraphQLInputObjectType, | ||
} from "graphql"; | ||
|
||
import { inputType, listType, toPrimitive } from "./utils"; | ||
|
||
export const printInputType = (type: GraphQLInputType): string => { | ||
const isList = listType(type); | ||
const base = inputType(type); | ||
|
||
return ( | ||
(() => { | ||
if (base instanceof GraphQLScalarType) { | ||
return toPrimitive(base); | ||
} else if (base instanceof GraphQLEnumType) { | ||
return base.name; | ||
} else if (base instanceof GraphQLInputObjectType) { | ||
return "I" + base.name; | ||
} else { | ||
throw new Error("Unable to render inputType."); | ||
} | ||
})() + (isList ? "[]" : "") | ||
); | ||
}; |
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
b16deb9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: