我工作的这个库https://github.com/ilyaskarim/wertik-js叫Wertik JS做GraphQL + REST API更容易,在解析器,当我控制台日志info
,它表明不确定的。 对于每个模块,我创建动态解析器,以使事情更容易为开发商谁将会使用这个库。
let object = {
create: async (_:any, args:any, context:any,info: any) => {
console.log(info); // This will be undefined
let v = await validate(validations.create,args.input);
let {success} = v;
if (!success) {
throw new ApolloError("Validation error",statusCodes.BAD_REQUEST.number,{list: v.errors})
}
try {
let createModel = await model.create(args.input);
pubsub.publish(`${camelCase(moduleName)}Created`, { [`${camelCase(moduleName)}Created`]: createModel });
return createModel;
} catch (e) {
return internalServerError(e);
}
},
}
行: https://github.com/ilyaskarim/wertik-js/blob/ec813f49a14ddd6a04680b261ae4ef2aadc2b1a5/src/framework/dynamic/resolvers.ts#L102
在阿波罗服务器文档中描述的信息https://www.apollographql.com/docs/apollo-server/essentials/data/#resolver-type-signature ,它说:这个自变量包含有关查询的执行状态信息,包括字段名,从根的路径,场,等等。 对我来说,不幸的是,它越来越不确定。
要重现该问题:
- 下载https://github.com/ilyaskarim/wertik-js/tree/development
- 纱线安装
- 转到例子/演示
- 运行
node index.js
- 现在去的http://本地主机:1209 /
输入此突变,例如:
突变{CREATEROLE(输入:{名: “性Asd”}){名称}}
- 该行执行这一突变https://github.com/ilyaskarim/wertik-js/blob/ec813f49a14ddd6a04680b261ae4ef2aadc2b1a5/src/framework/dynamic/resolvers.ts#L102
- 并返回未定义的控制台上。
这就是我设置的应用程序:
const { ApolloServer } = require('apollo-server');
import mutations from "./loadAllMutations";
import queries from "./loadAllQueries";
import resolvers from "./loadAllResolvers";
import subscriptions from "./loadAllSubscriptions";
import schemas from "./loadAllSchemas";
import generalSchema from "./../helpers/generalSchema";
export default function (rootDirectory: string,app: any,configuration: object) {
let allMutations = mutations(rootDirectory);
let allQueries= queries(rootDirectory);
let allSchemas = schemas(rootDirectory);
let allResolvers = resolvers(rootDirectory);
let allSubscriptions = subscriptions(rootDirectory);
let {validateAccessToken} = require(`${rootDirectory}/framework/predefinedModules/user/auth`).default;
let mainSchema = `
${generalSchema}
${allSchemas}
type Subscription {
${allSubscriptions}
}
type Mutation {
${allMutations}
}
type Query {
${allQueries}
}
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
`;
const server = new ApolloServer({
typeDefs: mainSchema,
resolvers: allResolvers,
context: async (a: any) => {
await validateAccessToken(a.req);
}
});
server.listen(1209).then(({ url, subscriptionsUrl }) => {
console.log(`Server ready at ${url}`);
console.log(`Subscriptions ready at ${subscriptionsUrl}`);
});
}
可能是什么可能的原因?