Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add payment status by hash query/subscription #3899

Merged
merged 11 commits into from
Feb 14, 2024

Conversation

dolcalmi
Copy link
Collaborator

No description provided.

@dolcalmi dolcalmi force-pushed the feat-add-payment-status-by-hash branch from a3cb01e to e94eb92 Compare February 7, 2024 16:15
@dolcalmi dolcalmi marked this pull request as ready for review February 7, 2024 17:31
@dolcalmi dolcalmi requested a review from vindard February 7, 2024 17:31
Copy link
Contributor

@vindard vindard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments about error handling and naming things

@@ -13,20 +13,28 @@ const LnInvoicePaymentStatusQuery = GT.Field({
},
resolve: async (_, args) => {
const { paymentRequest } = args.input
if (paymentRequest instanceof Error) throw paymentRequest
if (paymentRequest instanceof Error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I think we usually throw our errors for queries and return for mutations

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type payload contains error.. really not sure if was on purpose or because it is used to in subscription... do you remember?

resolve: async (_, args) => {
const { paymentHash } = args.input
if (paymentHash instanceof Error) {
return { errors: [{ message: paymentHash.message }] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we usually throw for queries and return only for mutations

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I copied the structure used in the original status query.. please check #3899 (comment)

@@ -27,6 +28,7 @@ export const queryFields = {
realtimePrice: RealtimePriceQuery,
btcPriceList: BtcPriceListQuery,
lnInvoicePaymentStatus: LnInvoicePaymentStatusQuery,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should do something like this just so it's clearer internally?

Suggested change
lnInvoicePaymentStatus: LnInvoicePaymentStatusQuery,
lnInvoicePaymentStatus: LnInvoicePaymentStatusByPaymentRequestQuery,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 0f67fbc


import { GT } from "@/graphql/index"
import { mapError } from "@/graphql/error-map"
import { mapAndParseErrorForGqlResponse } from "@/graphql/error-map"
import LnInvoicePaymentStatusPayload from "@/graphql/public/types/payload/ln-invoice-payment-status"
import LnInvoicePaymentStatusInput from "@/graphql/public/types/object/ln-invoice-payment-status-input"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here for whether we should be more specific internally

Suggested change
import LnInvoicePaymentStatusInput from "@/graphql/public/types/object/ln-invoice-payment-status-input"
import LnInvoicePaymentStatusByRequestInput from "@/graphql/public/types/object/ln-invoice-payment-status-by-request-input"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 0f67fbc although name remains the same to avoid breaking changes name: "LnInvoicePaymentStatusInput"

}
}

type LnInvoicePaymentResolveSource = {
errors?: IError[]
status?: string
paymentHash?: PaymentHash
paymentRequest?: EncodedPaymentRequest
}

const LnInvoicePaymentStatusSubscription = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
const LnInvoicePaymentStatusSubscription = {
const LnInvoicePaymentStatusByRequestSubscription = {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 0f67fbc

@dolcalmi dolcalmi force-pushed the feat-add-payment-status-by-hash branch 3 times, most recently from aa21f0a to ab07d54 Compare February 12, 2024 12:16
@github-actions github-actions bot added the pay label Feb 12, 2024
@dolcalmi dolcalmi added the core label Feb 12, 2024
@dolcalmi dolcalmi requested a review from vindard February 13, 2024 20:25
@dolcalmi dolcalmi force-pushed the feat-add-payment-status-by-hash branch from 901beda to 38f4a5f Compare February 14, 2024 14:08
Copy link
Contributor

@vindard vindard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants