graphql#isEnumType JavaScript Examples
The following examples show how to use
graphql#isEnumType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomArgs.js From graphene-graphiql-explorer with MIT License | 5 votes |
export function getDefaultScalarArgValue(parentField, arg, argType) {
const unwrappedType = unwrapOutputType(parentField.type);
switch (unwrappedType.name) {
case "GitHubRepository":
if (arg.name === "name") {
return { kind: "StringValue", value: "graphql-js" };
} else if (arg.name === "owner") {
return { kind: "StringValue", value: "graphql" };
}
break;
case "NpmPackage":
if (arg.name === "name") {
return { kind: "StringValue", value: "graphql" };
}
break;
default:
if (
isEnumType(argType) &&
unwrappedType.name.startsWith("GitHub") &&
unwrappedType.name.endsWith("Connection")
) {
if (
arg.name === "direction" &&
argType
.getValues()
.map(x => x.name)
.includes("DESC")
) {
return { kind: "EnumValue", value: "DESC" };
} else if (
arg.name === "field" &&
argType
.getValues()
.map(x => x.name)
.includes("CREATED_AT")
) {
return { kind: "EnumValue", value: "CREATED_AT" };
}
}
return GraphiQLExplorer.defaultValue(argType);
}
return GraphiQLExplorer.defaultValue(argType);
}