GraphQL - 为makeExecutableSchema导入typedef模式会创建未处理的promise

时间:2017-03-19 15:09:49

标签: javascript promise graphql

目前使用这2个样板用于最小的 GraphQL服务器和客户端实现,通过localhost连接。

https://github.com/apollographql/frontpage-server

https://github.com/apollographql/frontpage-react-app

在编辑和拆分类似于apollo文档的typdef时,当我在与其使用的typedef不同的文件中执行makeExecutableSchema时,我无法成功连接到服务器。我挂在网络上待处理。

import { makeExecutableSchema } from 'graphql-tools';
import resolvers from './resolvers';
import schema from './data/schema';
const modSchema = makeExecutableSchema({
  typeDefs: schema,
  resolvers: resolvers
});
export default modSchema`

我进入控制台: UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Must provide schema

因此,typedefs需要它是一个字符串或数组。而且我认为我需要在某个地方执行一个函数,以便在尝试从我的客户端访问服务器时满足未处理的承诺。当上面与它使用的typedef在同一个文件中时(根据上面的原始样板文件),这种方法有效。移动到单独的文件时,我将如何实现此目的?它是如何创建错误的?

0 个答案:

没有答案
相关问题