当前位置: 首页>>代码示例>>TypeScript>>正文


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

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