Skip to content

Commit

Permalink
fix: remove top level graphql-relay dependency (#9611)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch authored Apr 9, 2024
1 parent 537a8af commit 72fc294
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"graphql": "15.7.2",
"graphql-relay": "^0.10.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^7.0.4",
"jscodeshift": "^0.14.0",
Expand Down
23 changes: 22 additions & 1 deletion packages/client/shared/gqlIds/DomainJoinRequestId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
import {toGlobalId, fromGlobalId} from 'graphql-relay'
import {GraphQLID} from 'graphql'

/**
* Takes a type name and an ID specific to that type name, and returns a
* "global ID" that is unique among all types.
*/
const toGlobalId = (type: string, id: string | number) => {
return btoa([type, GraphQLID.serialize(id)].join(':'))
}

/**
* Takes the "global ID" created by toGlobalID, and returns the type name and ID
* used to create it.
*/
const fromGlobalId = (globalId: string) => {
const unbasedGlobalId = atob(globalId)
const delimiterPos = unbasedGlobalId.indexOf(':')
return {
type: unbasedGlobalId.substring(0, delimiterPos),
id: unbasedGlobalId.substring(delimiterPos + 1)
}
}

const DomainJoinRequestId = {
join: (id: number): string => toGlobalId('DomainJoinRequest', id),
Expand Down

0 comments on commit 72fc294

Please sign in to comment.