Giter VIP home page Giter VIP logo

spring-petclinic-graphql's Introduction

GraphQL version of Spring PetClinic Sample Application

This is a GraphQL API version of the Spring PetClinic Application. It consists of two parts:

  • The Spring Boot-based backend, that uses the graphql-java implementation for the server-side GraphQL Api implementation
  • The React-based frontend, that uses React Apollo for running GraphQL queries.

Note This project is in very early stage and has much room for improvement! If you like to help, I'd be more than happy! You can for example open an issue for discussing things or a Pull Request to contribute.

The Backend

The backend code in this repository is based on the Rest example https://github.com/spring-petclinic/spring-petclinic-rest. Instead of the org.springframework.samples.petclinic.rest package it contains a org.springframework.samples.petclinic.graphql package that contains the resolvers for the GraphQL API.

GraphQL Java implementation

GraphQL frameworks used in this example:

The frontend

The frontend is implemented in TypeScript and uses React for the UI.

GraphQL frameworks used in the frontend:

Running petclinic locally

First clone the application:

git clone https://github.com/spring-petclinic/spring-petclinic-graphql.git

Then build and start the SpringBoot backend using Maven:

cd spring-petclinic-graphql/backend
./mvnw spring-boot:run

Finally build and start the frontend:

cd spring-petclinic-graphql/frontend
# install dependencies
yarn install
	
# start application
yarn start

After running you can access:

SpringBoot PetClinic, GraphQL Edition

Contributing

If you like to help and contribute you're more than welcome! Please open an issue or a Pull Request

Contact

You can find me on Twitter.

From the original PetClinic README

Understanding the Spring Petclinic application with a few diagrams

See the presentation here

Database configuration

(Note: this is unrelated to GraphQL)

In its default configuration, Petclinic uses an in-memory database (HSQLDB) which gets populated at startup with data. A similar setups is provided for MySql and PostgreSQL in case a persistent database configuration is needed. To run petclinic locally using persistent database, it is needed to change profile defined in application.properties file.

For MySQL database, it is needed to change param "hsqldb" to "mysql" in string

spring.profiles.active=hsqldb,spring-data-jpa

defined in application.properties file.

Before do this, would be good to check properties defined in application-mysql.properties file.

spring.datasource.url = jdbc:mysql://localhost:3306/petclinic?useUnicode=true
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.username=root 
spring.datasource.password=petclinic 
spring.datasource.driver-class-name=com.mysql.jdbc.Driver 
spring.jpa.database=MYSQL 
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=none

You may also start a MySql database with docker:

docker run --name mysql-petclinic -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8

For PostgeSQL database, it is needed to change param "hsqldb" to "postgresql" in string

spring.profiles.active=hsqldb,spring-data-jpa

defined in applcation.properties file.

Before do this, would be good to check properties defined in application-postgresql.properties file.

spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=petclinic
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database=POSTGRESQL
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none

You may also start a Postgres database with docker:

docker run --name postgres-petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 -d postgres:9.6.0

spring-petclinic-graphql's People

Contributors

arey avatar vfedoriv avatar nilshartmann avatar cyrille-leclerc avatar gordonad avatar tduchateau avatar trepel avatar freemansoft avatar liouxiao avatar rstoyanchev avatar verydapeng avatar thinkshihang avatar srenkens avatar patrickcrocker avatar mklose avatar lukasz-szewc avatar boly38 avatar vladfau avatar tejasm avatar babinslava avatar meltsufin avatar craigsdennis avatar colinbut avatar cbeams avatar bram-atmire avatar helloworld123122344134 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.