Skip to content

Commit

Permalink
hashing fn update
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Jan 20, 2024
1 parent 49f5a46 commit 1fb43f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-js-tree",
"version": "1.0.7",
"version": "1.0.8",
"private": false,
"license": "MIT",
"description": "GraphQL Parser providing simplier structure",
Expand Down
1 change: 0 additions & 1 deletion src/TreeOperations/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const mergeNode = (n1: ParserField, n2: ParserField) => {
const args = [...n1.args, ...n2.args.map(addFromLibrary)];
const mergedNode = {
...n1,
id: generateNodeId(n1.name, n1.data.type, args),
args,
directives: [...n1.directives, ...n2.directives.map(addFromLibrary)],
interfaces: [...n1.interfaces, ...n2.interfaces],
Expand Down
6 changes: 4 additions & 2 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ export const decompileType = (typeName: string): FieldType => {
};

export const generateNodeId = (name: string, dataType: AllTypes, args: ParserField[]) => {
const s = [name, dataType, isExtensionNode(dataType) ? args.map((a) => a.id).join('-') : ''].join('-');
return cyrb53(s);
const s = isExtensionNode(dataType)
? `${name}-extend-${cyrb53(JSON.stringify(args.map((a) => a.name + a.id)))}`
: name;
return s;
};
const cyrb53 = (str: string, seed = 0) => {
let h1 = 0xdeadbeef ^ seed,
Expand Down

0 comments on commit 1fb43f2

Please sign in to comment.