在Eclipse MicroProfile API 之后声明了您的服务器端突变,如下所示:
@GraphQLApi
@ApplicationScoped
public class MyGraphQLApi {
@Mutation
public OutputType add(@Name("p") InputType p)) {
// perform your mutation and return result
}
}
然后,您可以使用在您的突变结构之后构造的方法以DynamicGraphQLClient
声明方式使用该DynamicGraphQLClient#executeSync
方法执行突变:io.smallrye.graphql.client.core.Document
@Inject
private DynamicGraphQLClient client;
public void add() {
Document document = document(
operation(
OperationType.MUTATION,
"mut",
field(
"add",
arg(
"p",
inputObject(
prop("amount", "amountValue"),
prop("fromCurrencyId", "fromCurrencyIdValue"),
prop("reference", "referenceValue"),
prop("terminalKey", "terminalKeyValue"),
prop("toCurrencyId", "toCurrencyIdValue"),
)
),
field("address"),
field("toCurrencyAmount"),
field("rate"),
field("createdAt"),
field("expireAt")
)
)
);
JsonObject data = client.executeSync(document).getData();
System.out.println(data.getString("address"));
}