本文整理汇总了TypeScript中graphql.isNamedType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNamedType函数的具体用法?TypeScript isNamedType怎么用?TypeScript isNamedType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNamedType函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: resolveType
const resolveType = <T extends GraphQLType>(type: T): T | GraphQLType => {
if (type instanceof GraphQLList) {
const innerType = resolveType(type.ofType);
if (innerType === null) {
return null;
} else {
return new GraphQLList(innerType) as T;
}
} else if (type instanceof GraphQLNonNull) {
const innerType = resolveType(type.ofType);
if (innerType === null) {
return null;
} else {
return new GraphQLNonNull(innerType) as T;
}
} else if (isNamedType(type)) {
const typeName = getNamedType(type).name;
switch (typeName) {
case GraphQLInt.name:
return GraphQLInt;
case GraphQLFloat.name:
return GraphQLFloat;
case GraphQLString.name:
return GraphQLString;
case GraphQLBoolean.name:
return GraphQLBoolean;
case GraphQLID.name:
return GraphQLID;
default:
return getType(typeName, type);
}
} else {
return type;
}
};
开发者ID:apollostack,项目名称:graphql-tools,代码行数:35,代码来源:schemaRecreation.ts
示例2: GraphQLList
public resolveType<T extends GraphQLType>(type: T): T {
if (type instanceof GraphQLList) {
return new GraphQLList(this.resolveType(type.ofType)) as T;
} else if (type instanceof GraphQLNonNull) {
return new GraphQLNonNull(this.resolveType(type.ofType)) as T;
} else if (isNamedType(type)) {
return this.getType(getNamedType(type).name) as T;
} else {
return type;
}
}
开发者ID:sventschui,项目名称:graphql-tools,代码行数:11,代码来源:TypeRegistry.ts
示例3: isSpecifiedScalarType
export default function isSpecifiedScalarType(type: any): boolean {
return (
isNamedType(type) &&
// Would prefer to use specifiedScalarTypes.some(), however %checks needs
// a simple expression.
(type.name === GraphQLString.name ||
type.name === GraphQLInt.name ||
type.name === GraphQLFloat.name ||
type.name === GraphQLBoolean.name ||
type.name === GraphQLID.name)
);
}
开发者ID:apollostack,项目名称:graphql-tools,代码行数:12,代码来源:isSpecifiedScalarType.ts
示例4: isNamedType
Object.keys(typeMap).forEach(typeName => {
const type: GraphQLType = typeMap[typeName];
if (
isNamedType(type) &&
getNamedType(type).name.slice(0, 2) !== '__' &&
type !== queryType &&
type !== mutationType
) {
let newType;
if (isCompositeType(type) || type instanceof GraphQLInputObjectType) {
newType = recreateCompositeType(schema, type, typeRegistry);
} else {
newType = getNamedType(type);
}
typeRegistry.addType(newType.name, newType, onTypeConflict);
}
});
开发者ID:sventschui,项目名称:graphql-tools,代码行数:17,代码来源:mergeSchemas.ts
示例5: GraphQLList
function healType<T extends GraphQLType>(type: T): T {
// Unwrap the two known wrapper types
if (type instanceof GraphQLList) {
type = new GraphQLList(healType(type.ofType)) as T;
} else if (type instanceof GraphQLNonNull) {
type = new GraphQLNonNull(healType(type.ofType)) as T;
} else if (isNamedType(type)) {
// If a type annotation on a field or an argument or a union member is
// any `GraphQLNamedType` with a `name`, then it must end up identical
// to `schema.getType(name)`, since `schema.getTypeMap()` is the source
// of truth for all named schema types.
const namedType = type as GraphQLNamedType;
const officialType = schema.getType(namedType.name);
if (officialType && namedType !== officialType) {
return officialType as T;
}
}
return type;
}
开发者ID:apollostack,项目名称:graphql-tools,代码行数:19,代码来源:schemaVisitor.ts
示例6: getTypeSpecifiers
Object.keys(typeMap).map((typeName: string) => {
const type = typeMap[typeName];
if (isNamedType(type) && getNamedType(type).name.slice(0, 2) !== '__') {
const specifiers = getTypeSpecifiers(type, schema);
const typeVisitor = getVisitor(visitor, specifiers);
if (typeVisitor) {
const result: GraphQLNamedType | null | undefined = typeVisitor(
type,
schema,
);
if (typeof result === 'undefined') {
types[typeName] = recreateType(type, resolveType, !stripResolvers);
} else if (result === null) {
types[typeName] = null;
} else {
types[typeName] = recreateType(result, resolveType, !stripResolvers);
}
} else {
types[typeName] = recreateType(type, resolveType, !stripResolvers);
}
}
});
开发者ID:apollostack,项目名称:graphql-tools,代码行数:22,代码来源:visitSchema.ts
注:本文中的graphql.isNamedType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论