Skip to content

Instantly share code, notes, and snippets.

module.exports = {
departments: [
{ id: 1, dept_name: "Lorem Ipsum" },
{ id: 2, dept_name: "Sic Dolor amet" },
],
employees: [
{
id: 123,
first_name: "John Doe",
last_name: "Last",
[gist id="9b1307f153f4abe352a4" file="media-control-snippet.php"]
@SpringBootTest(classes = { DgsAutoConfiguration.class, DateScalar.class, EmployeePhotoUploadDataFetcher.class })
public class EmployeePhotoUploadDataFetcherTest {
@Autowired
DgsQueryExecutor dgsQueryExecutor;
@Autowired
EmployeePhotoUploadDataFetcher empPhotoUploader;
@Test
scalar Upload
type Mutation {
uploadEmployeePhoto(emp_id: Int! ,inputFile : Upload!): String
}
query GetEmployee ($id : Int){
employee(id :$id){
first_name
last_name
}
}
mutation createEmployee ($employee : SubmittedEmployee){
createEmployee (employee : $employee) {
id
query GetEmployee{
employee(id :1){
first_name
last_name
}
}
query GetEmployeeWithDept{
employee(id :1){
first_name
query {
employee(id :1){
first_name
last_name
}
}
mutation {
createEmployee (employee :{first_name: "Alex" ,last_name : "Peak" ,gender : M ,deptId:1}) {
id
first_name
}
}
@Test
public void test_notifyEmployeeCreation() throws JsonMappingException, JsonProcessingException {
ExecutionResult notifyEmployeeCreationSubscription = dgsQueryExecutor.execute(
"subscription { notifyEmployeeCreation { id first_name last_name gender hire_date birth_date} }");
Publisher<ExecutionResult> publisher = notifyEmployeeCreationSubscription.getData();
publisher.subscribe(new Subscriber<ExecutionResult>() {
@Override
@DgsComponent
public class EmployeeDataFetcher {
private FluxSink<Employee> employeeStream;
private ConnectableFlux<Employee> employeePublisher;
@PostConstruct
public void init() {