• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript graphql.isNamedType函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript graphql.parse函数代码示例发布时间:2022-05-25
下一篇:
TypeScript graphql.isAbstractType函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap