我是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) 我有一个静态 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)