smallrye-graphql: Some parameter are not getting mapped in the Input class

We have defined a graphql method that generates this schema:

mutation { collectionPaymentsCreate( collectionPayments: { cashRegisterId: “65a0c514-0a02-4eca-97e8-de71495ba3f9” customerId: “bddf6de2-db3f-4e74-9afd-33e4a4d45626” branchId: “6f304ded-9078-49ea-b932-c00854d75247” sellerId: “7ca42902-5c77-45a2-a1f4-1d4e56c23c82” paymentFormId: “66a30334-eb84-4f46-b5e9-73e52af98229” currencyId: “8e799f20-17dd-41a6-9089-95acbf418f3b” paymentStatusId: “1944823c-c577-482f-9d71-3c3c2b4cd433” documentType: “a6fca760-f738-4ee5-b685-601532dd2b8f” collectionAccountId: 802716263 customerAccountId: 574833393 retentionTypeId: “58bc866d-5c2b-4305-b12a-05dd0011d9c3” collectionId: “ac75c1f8-ee22-409a-8cd2-a15006e4987e” xId: “95090f21-6e21-4048-8901-2312e58dcc5a” zId: “13c9b2e0-0650-4d39-a3a3-ff9cac7128e5” documentNumber: 8663838971428344963 series: “16646” issuedDate: “2024-07-03T18:33:56.719792700” returnedDate: “2024-07-03T18:33:56.719792700” canceledDate: “2024-07-03T18:33:56.719792700” documentReference: 231956995 documentSeries: “377976” amount: 8.460966165622535E8 comment: “325163028” printed: true exchangeRate: 6.370691098868833E8 multipleCollection: true transactionNumber: 453223353 retentionAmount: 1.4482197106224442E8 lineNumber: 7634103834451622320 accounted: true accountedReturned: true seatId: 800237185 type: 7984437249198708856 } ) { id cashRegisterId customerId branchId sellerId createdBy paymentFormId currencyId paymentStatusId documentType collectionAccountId customerAccountId retentionTypeId collectionId xId zId documentNumber series issuedDate returnedDate canceledDate creationDate documentReference documentSeries amount comment printed exchangeRate multipleCollection transactionNumber retentionAmount lineNumber accounted accountedReturned seatId type } }

Even though we send the parameters xId and zId with values, they are not getting mapped in the Input object. I believe it has something to be with variable names, because these two are the only two values that don’t get mapped. This is not the only method that defines these two variables, there are many graphql methods that define xId and zId and in none of them are getting mapped.

With the payload specified above, this is what happens:

image

These three fields are defined as follows:

var xId: UUID? = null
var zId: UUID? = null
var registerId: UUID? = null

However the registerId gets mapped correctly, but neither xId nor zId get mapped. Again this is not the only method in which we define xId and zId, however in none of them get mapped, it fails in each and every method. It has to be something with the variable names.

Thanks in advance.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 27 (14 by maintainers)

Most upvoted comments

PropertyNamingStrategy.CASE_INSENSITIVE seems to fix the problem.

JsonbConfig config = new JsonbConfig()
                .withPropertyNamingStrategy(PropertyNamingStrategy.CASE_INSENSITIVE);
Jsonb json = JsonBCreator.getJsonB("com.mundoware.business.finance.collectionPayments.CollectionPaymentsInput");
Jsonb json2 = JsonbBuilder.create(config);
String jsonString = """
        {
          "name": "ASD ASDAS",
          "xid": "1b768067-0212-462f-88da-b5ecf0537e41",
          "yId": "1b768067-0212-462f-88da-b5ecf0537e41",
          "zId": "1b768067-0212-462f-88da-b5ecf0537e41"
        }
""";
CollectionPaymentsInput collectionPaymentsInput = json.fromJson(jsonString, CollectionPaymentsInput.class);

System.out.println(collectionPaymentsInput.getName());
System.out.println(collectionPaymentsInput.getXid());
System.out.println(collectionPaymentsInput.getYId());
System.out.println(collectionPaymentsInput.getZId());

System.out.println("==============JSONBUILDER DEFAULT CONFIG=============");

collectionPaymentsInput = json2.fromJson(jsonString, CollectionPaymentsInput.class);

System.out.println(collectionPaymentsInput.getName());
System.out.println(collectionPaymentsInput.getXid());
System.out.println(collectionPaymentsInput.getYId());
System.out.println(collectionPaymentsInput.getZId());
ASD ASDAS
1b768067-0212-462f-88da-b5ecf0537e41
null
null
==============JSONBUILDER DEFAULT CONFIG=============
ASD ASDAS
1b768067-0212-462f-88da-b5ecf0537e41
1b768067-0212-462f-88da-b5ecf0537e41
1b768067-0212-462f-88da-b5ecf0537e41

Yes there’s a @JsonbProperty but after annotating fields, it still does not work:

image

ASD ASDAS
1b768067-0212-462f-88da-b5ecf0537e41
null
null
==============JSONBUILDER DEFAULT CONFIG=============
ASD ASDAS
1b768067-0212-462f-88da-b5ecf0537e41
null
null

@miltonlm Have you tried adding @JsonbProperty("...") onto the setters? That seems to work on my end. (not sure how it will be handled in kotlin)