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 поддерживает любое решение для пространства имен?