【发布时间】:2019-01-25 07:35:46
【问题描述】:
import { makeExecutableSchema } from 'graphql-tools';
const fish = { length:50 },
rope = { length:100 };
const typeDefs = `
type Query {
rope: Rope!
fish: Fish!
}
type Mutation {
increase_fish_length: Fish!
increase_rope_length: Rope!
}
type Rope {
length: Int!
}
type Fish {
length: Int!
}
`;
const resolvers = {
Mutation: {
increase_fish_length: (root, args, context) => {
fish.length++;
return fish;
},
increase_rope_length: (root, args, context) => {
rope.length++;
return rope;
}
}
};
export const schema = makeExecutableSchema({ typeDefs, resolvers });
以上示例运行良好,但我想使用突变名称 increase_length 而不是 increase_fish_length 和 increase_rope_length。
我尝试使用斜线命名突变 Fish/increase_length 和 Rope/increase_length,但没有成功。 (只有 /[_A-Za-z][_0-9A-Za-z]*/ 可用。)
Dose GraphQl 支持命名空间的任何解决方案吗?
【问题讨论】:
标签: javascript graphql graphql-tools