using System.Threading.Tasks;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
using System.Collections.Generic;
public class DefaultWalletIdResponse
public string userDefaultWalletId { get; set; }
public class InvoiceResponse
public MutationData mutationData { get; set; }
public class MutationData
public Invoice invoice { get; set; }
public List<Error> errors { get; set; }
public string paymentRequest { get; set; }
public string message { get; set; }
public static async Task Main()
var graphQLClient = new GraphQLHttpClient("https://api.staging.galoy.io/graphql", new NewtonsoftJsonSerializer());
var defaultWalletIdQuery = new GraphQLRequest {
query userDefaultWalletId($username: Username!) {
userDefaultWalletId(username: $username)
OperationName = "userDefaultWalletId",
var graphQLResponse = await graphQLClient.SendQueryAsync<DefaultWalletIdResponse>(defaultWalletIdQuery);
Console.WriteLine("raw response:");
Console.WriteLine(JsonSerializer.Serialize(graphQLResponse, new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine($"WalletId: {graphQLResponse.Data.userDefaultWalletId}");
var createNoAmountInvoiceMutation = new GraphQLRequest {
mutation lnNoAmountInvoiceCreateOnBehalfOfRecipient($walletId: WalletId!) {
mutationData: lnNoAmountInvoiceCreateOnBehalfOfRecipient(
input: { recipientWalletId: $walletId }
OperationName = "lnNoAmountInvoiceCreateOnBehalfOfRecipient",
walletId = graphQLResponse.Data.userDefaultWalletId
var invoiceResponse = await graphQLClient.SendMutationAsync<InvoiceResponse>(createNoAmountInvoiceMutation);
Console.WriteLine("raw response:");
Console.WriteLine(JsonSerializer.Serialize(invoiceResponse, new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine($"Invoice: {invoiceResponse.Data.mutationData.invoice.paymentRequest}");