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

TypeScript graphql-import.importSchema函数代码示例

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

本文整理汇总了TypeScript中graphql-import.importSchema函数的典型用法代码示例。如果您正苦于以下问题:TypeScript importSchema函数的具体用法?TypeScript importSchema怎么用?TypeScript importSchema使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了importSchema函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: require

   folders.forEach(folder => {
     const { resolvers } = require(`../modules/${folder}/resolvers`);
     const typeDefs = importSchema(
       path.join(__dirname, `../modules/${folder}/schema.graphql`)
     );
 
     // Make a schema for each folder in module and store the schema for each folder
     // in the schema array
     schemas.push(
       makeExecutableSchema({ resolvers, typeDefs })
     );
   })
开发者ID:itaygolan,项目名称:GraphQL-Typescript-Server,代码行数:12,代码来源:generateSchema.ts


示例2: readSchema

export function readSchema(path): GraphQLSchema {
  // FIXME: prefix error
  switch (extname(path)) {
    case '.graphql':
      return valueToSchema(importSchema(path))
    case '.json':
      const data = readFileSync(path, { encoding: 'utf-8' })
      const introspection = JSON.parse(data)
      return valueToSchema(introspection)
    default:
      throw new Error(
        'Unsupported schema file extention. Only ".graphql" and ".json" are supported',
      )
  }
}
开发者ID:graphcool,项目名称:graphql-config,代码行数:15,代码来源:utils.ts


示例3: makeExecutableSchema

import { processRequest } from 'apollo-upload-server';
import * as graphqlHTTP from 'express-graphql';
import { graphql, printSchema } from 'graphql';
import { importSchema } from 'graphql-import';
import { makeExecutableSchema } from 'graphql-tools';
import { SampleService } from '../services';

const dirname = process.env.LAMBDA_TASK_ROOT ? `${process.env.LAMBDA_TASK_ROOT}/app/graphql` : __dirname;

export const schema = makeExecutableSchema({
  typeDefs: importSchema(`${dirname}/index.graphql`),
  resolvers: [
    SampleService.resolvers,
  ],
});

const middleware = graphqlHTTP((request, response?, graphQLParams?) => {
  if (graphQLParams) {
    request.body = {
      query: graphQLParams.query && graphQLParams.query.replace(/\s+/g, ' '),
      variables: graphQLParams.variables,
      operationName: graphQLParams.operationName,
    };
  }
  return {
    schema,
    graphiql: process.env.NODE_ENV !== 'production',
    extensions: ({ result }) => {
      (response as any).errors = result.errors;
      return {};
    },
开发者ID:june1123,项目名称:testSources,代码行数:31,代码来源:index.ts


示例4: importSchema

          id
          file
        }
        previousValues {
          id
          file
        }
      }`
        );
      }
    }
  }
};
//console.log(db.subscription.organization)
const firstSchema = importSchema(
  path.join(__dirname, "./generated/prisma.graphql")
);
const secondSchema = importSchema(path.join(__dirname, "./schema.graphql"));
const schema = makeExecutableSchema({ typeDefs: firstSchema });
//addMockFunctionsToSchema({ schema });
const schema2 = makeExecutableSchema({ typeDefs: secondSchema });
//addMockFunctionsToSchema({ schema:schema2 });

//const schemas = [firstSchema, secondSchema];

export const ultimateSchema = mergeSchemas({
  schemas: [schema, schema2],
  resolvers
});
//console.log(ultimateSchema.getSubscriptionType().getFields())
开发者ID:simonjoom,项目名称:react-native-project,代码行数:30,代码来源:resolv.ts


示例5: importSchema

import { makeExecutableSchema } from 'graphql-tools';
import { nodeInterface, pageInfoType } from 'graphql-relay-tools';
import { importSchema } from 'graphql-import';

import resolvers from './resolvers';

import { swapiDef } from './schema/swapi';

const schemas = {
  nodeInterface,
  pageInfoType,
  ...swapiDef,
};

const typeDefs: string = importSchema('src/graphql/schema/schema.graphql', schemas);

const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
});

export default schema;
开发者ID:Alexandr-Baluhin,项目名称:nodejs-graphql-template,代码行数:22,代码来源:schema.ts



注:本文中的graphql-import.importSchema函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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