Don't use murmurhash

This commit is contained in:
Chi Vinh Le
2017-12-01 17:11:38 +01:00
parent 612d2596f9
commit c2b488fa98
@@ -6,10 +6,24 @@ import {
getOperationDefinition,
} from 'apollo-utilities';
import {murmur3} from 'murmurhash-js';
function getDirectivesID(directives) {
return murmur3(JSON.stringify(directives));
let id = '';
directives.forEach((directive) => {
id += `@${directive.name.value}(`;
let first = true;
directive.arguments.forEach((arg) => {
if (!first) {
id += ',';
}
first = false;
const value = arg.value.kind === 'Variable'
? `$${arg.value.name.value}`
: arg.value.value;
id += `${arg.name.value}:${value}`;
});
id += ')';
});
return id;
}
// If two definitions have the same id, they can be merged.