io.smallrye.graphql.client.core.Variable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smallrye-graphql-client-api Show documentation
Show all versions of smallrye-graphql-client-api Show documentation
SmallRye specific Client API, extending the MicroProfile client api, allowing us to play with the api first before we move it to the spec
package io.smallrye.graphql.client.core;
import static io.smallrye.graphql.client.core.VariableType.varType;
import static io.smallrye.graphql.client.core.utils.ServiceUtils.getNewInstanceOf;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import java.util.List;
import java.util.Optional;
public interface Variable extends Buildable {
/*
* Helpers
*/
static List vars(Variable... vars) {
return asList(vars);
}
// (name, scalarType)
static Variable var(String name, ScalarType scalarType) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(scalarType));
var.setDefaultValue(Optional.empty());
var.setDirectives(emptyList());
return var;
}
// (name, scalarType, directives)
static Variable varWithDirectives(String name, ScalarType scalarType, List directives) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(scalarType));
var.setDefaultValue(Optional.empty());
var.setDirectives(directives);
return var;
}
// (name, scalarType, defaultValue)
static Variable var(String name, ScalarType scalarType, Object defaultValue) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(scalarType));
var.setDefaultValue(Optional.of(defaultValue));
var.setDirectives(emptyList());
return var;
}
// (name, scalarType, defaultValue, directives)
static Variable varWithDirectives(String name,
ScalarType scalarType,
Object defaultValue,
List directives) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(scalarType));
var.setDefaultValue(Optional.of(defaultValue));
var.setDirectives(directives);
return var;
}
// (name, objectType)
static Variable var(String name, String objectTypeName) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(objectTypeName));
var.setDefaultValue(Optional.empty());
var.setDirectives(emptyList());
return var;
}
// (name, objectType, directives)
static Variable varWithDirectives(String name, String objectTypeName, List directives) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(objectTypeName));
var.setDefaultValue(Optional.empty());
var.setDirectives(directives);
return var;
}
// (name, objectType, defaultValue)
static Variable var(String name, String objectTypeName, Object defaultValue) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(objectTypeName));
var.setDefaultValue(Optional.of(defaultValue));
var.setDirectives(emptyList());
return var;
}
// (name, objectType, defaultValue, directives)
static Variable varWithDirectives(String name, String objectTypeName, Object defaultValue, List directives) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType(objectTypeName));
var.setDefaultValue(Optional.of(defaultValue));
var.setDirectives(directives);
return var;
}
// (name, variableType)
static Variable var(String name, VariableType varType) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType);
var.setDefaultValue(Optional.empty());
var.setDirectives(emptyList());
return var;
}
// (name, variableType, directives)
static Variable varWithDirectives(String name, VariableType varType, List directives) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType);
var.setDefaultValue(Optional.empty());
var.setDirectives(directives);
return var;
}
// (name, variableType, defaultValue)
static Variable var(String name, VariableType varType, Object defaultValue) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType);
var.setDefaultValue(Optional.of(defaultValue));
var.setDirectives(emptyList());
return var;
}
// (name, variableType, defaultValue, directives)
static Variable varWithDirectives(String name, VariableType varType, Object defaultValue, List directives) {
Variable var = getNewInstanceOf(Variable.class);
var.setName(name);
var.setType(varType);
var.setDefaultValue(Optional.of(defaultValue));
var.setDirectives(directives);
return var;
}
/*
* Getter/Setter
*/
String getName();
void setName(String name);
VariableType getType();
void setType(VariableType value);
Optional