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 支持命名空间的任何解决方案吗?