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 });


上面的示例运行良好,但是我想使用一个变异名称“ increment_length”而不是“ increase_fish_length”和“ increase_rope_length”。

我尝试使用斜杠将突变Fish / increase_length和Rope / increase_length命名,但是没有用。 (仅/ [_ A-Za-z] [_ 0-9A-Za-z] * /可用。)

GraphQl是否支持任何名称空间解决方案?

最佳答案

Graphql不支持名称空间之类的东西

09-25 19:04