-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate more server wallet code (#1309)
* Generate more code from wallet defs * generate "type WalletLND { ... }" * generate "union WalletDetails = WalletLND | ..." * hardcode function for __resolveType * add comments where updates are needed if another server wallet is added * Fix type for LN addresses * Generate __resolveType from wallet.type column
- Loading branch information
Showing
4 changed files
with
79 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
export function fieldToGqlArg (field) { | ||
let arg = `${field.name}: String` | ||
if (!field.optional) { | ||
arg += '!' | ||
} | ||
return arg | ||
} | ||
|
||
export function generateResolverName (walletField) { | ||
const capitalized = walletField[0].toUpperCase() + walletField.slice(1) | ||
return `upsert${capitalized}` | ||
} | ||
|
||
export function generateTypeDefName (walletField) { | ||
return walletField[0].toUpperCase() + walletField.slice(1) | ||
} | ||
|
||
export function walletTypeToResolveType (walletType) { | ||
// wallet type is in UPPER_CASE but __resolveType requires PascalCase | ||
const PascalCase = walletType.split('_').map(s => s[0].toUpperCase() + s.slice(1)).join() | ||
return `Wallet${PascalCase}` | ||
} |