The backend is developed using Spring boot 2, the GraphQL Java implementation and the Spring boot starter.
No additional installation is necessary before being able to run the application. However, you can always load the dependencies and generate the JAR file using the following command:
./mvnw clean package
The backend can be ran properly without any additional configuration. However, the demo code used a hardcoded profile ID to store new questions and answers. So to make this example work, it's recommended to create a file called tech-talk-api/src/main/resources/data.sql and to include the following content:
INSERT INTO profile (id, username, title, email, bio) VALUES
(1, 'g00glen00b', 'Software engineer', '[email protected]', 'Consultant at Cronos and Tech lead at Aquafin. Usually you can find me trying out new libraries and technologies. Loves both Java and JavaScript.');
Obviously, you're free to change the data to whatever you'd like.
To run the application, you can use the following Maven command:
./mvnw spring-boot:run
This will compile the application and run it at port 8080.
The frontend is developed using Angular 7 and Apollo GraphQL.
To install the required dependencies, you can use the following command:
npm install
No additional configuration is required.
To run the application, you can use the following npm script:
npm start
The following snippets have been used during the presentation:
type Organization {
id: ID!
name: String
employees: [Employee]
employeeCount: Int
}
type Query {
organizations(offset: Int, limit: Int): [Organization]
organization(id: ID!): Organization
organizationCount: Int
employees(offset: Int, limit: Int): [Employee]
employee(id: ID): Employee
employeeCount: Int
}
type Mutation {
createOrganization(input: OrganizationInput!): Organization
deleteOrganization(id: ID!): Boolean
}
input OrganizationInput {
name: String
}
public int getEmployeeCount(Organization organization) {
return employeeRepo.countByOrganization(organization);
}
return {
employeeCount: ({id}) => Employee.count({organization: id})
};
query AllOrganizations($offset: Int, $limit: Int) {
organizations(offset: $offset, limit: $limit) {
id
name
employeeCount
}
}
{"offset": 0, "limit": 10}