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]*/可用。)
GraphQl 是否支持命名空间的任何解决方案?
最佳答案
Graphql 不支持类似命名空间的东西
关于javascript - 如何解决 GraphQL 中的命名冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51909282/