forked from GaloyMoney/blink
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check to see if npub is a flash npub (#109)
* Add is flash npub * Fix query * Make errors more specific
- Loading branch information
Showing
6 changed files
with
85 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { GT } from "@graphql/index" | ||
import { Accounts } from "@app" | ||
import { | ||
IsFlashNpubInput, | ||
IsFlashNpubPayload, | ||
} from "@graphql/public/types/object/is-flash-npub" | ||
import Npub from "@graphql/shared/types/scalar/npub" | ||
import { RepositoryError } from "@domain/errors" | ||
|
||
const IsFlashNpubQuery = GT.Field({ | ||
type: IsFlashNpubPayload, | ||
args: { | ||
input: { | ||
type: GT.NonNull(IsFlashNpubInput), | ||
}, | ||
}, | ||
resolve: async (_, args) => { | ||
const { | ||
input: { npub }, | ||
} = args | ||
if (npub instanceof Error) { | ||
throw npub | ||
} | ||
const output = await Accounts.findByNpub(npub) | ||
if (output instanceof RepositoryError) return { isFlashNpub: false } | ||
else if (output instanceof Error) throw output | ||
return { | ||
isFlashNpub: true, | ||
} | ||
}, | ||
}) | ||
|
||
export default IsFlashNpubQuery |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { GT } from "@graphql/index" | ||
import IError from "../../../shared/types/abstract/error" | ||
import Npub from "@graphql/shared/types/scalar/npub" | ||
|
||
const IsFlashNpubInput = GT.Input({ | ||
name: "IsFlashNpubInput", | ||
fields: () => ({ | ||
npub: { type: GT.NonNull(Npub) }, | ||
}), | ||
}) | ||
|
||
const IsFlashNpubPayload = GT.Object({ | ||
name: "IsFlashNpubPayload", | ||
fields: () => ({ | ||
errors: { | ||
type: GT.NonNullList(IError), | ||
}, | ||
isFlashNpub: { type: GT.Boolean }, | ||
}), | ||
}) | ||
|
||
export { IsFlashNpubInput, IsFlashNpubPayload } |