小编Ant*_*y C的帖子

如何在GraphQLSchema中定义多个查询或变异

我是GraphQL的新手.如果这很明显,请原谅我.

除了使用之外buildSchema,有没有办法使用new GraphQLSchema?定义多个查询/变异?

这就是我现在所拥有的.

const schema = new graphql.GraphQLSchema(
    {
        query: new graphql.GraphQLObjectType({
            name: 'RootQueryType',
            fields: {
                count: {
                    type: graphql.GraphQLInt,
                    resolve: function () {
                        return count;
                    }
                }
            }
        }),
        mutation: new graphql.GraphQLObjectType({
            name: 'RootMutationType',
            fields: {
                updateCount: {
                    type: graphql.GraphQLInt,
                    description: 'Updates the count',
                    resolve: function () {
                        count += 1;
                        return count;
                    }
                }
            }
        })
    });
Run Code Online (Sandbox Code Playgroud)

graphql

6
推荐指数
1
解决办法
2655
查看次数

可以在 HashMap 中获取、放置和删除元素而不进行迭代导致 ConcurrentModificationException 吗?

我有一个静态 hashMap,与多个线程共享。我根本没有迭代地图,只是使用get, put, remove。安全吗ConcurrentModificationException

该方法看起来像这样

private static Map<Long, Integer> TRACKER = new HashMap<Long,Integer>();
public static void track(Long tid, boolean b) {
        if (b) {
            if (TRACKER.containsKey(tid)) {
                TRACKER.put(tid, TRACKER.get(tid) + 1);
            } else {
                TRACKER.put(tid, 1);
            }
        } else {
            Integer n = TRACKER.get(tid);
            if (n != null) {
                n = n -1;
                if (n == 0) {
                    TRACKER.remove(tid);
                } else {
                    TRACKER.put(tid, n);
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

java hashmap concurrentmodification

3
推荐指数
1
解决办法
126
查看次数

标签 统计

concurrentmodification ×1

graphql ×1

hashmap ×1

java ×1