Code Monkey home page Code Monkey logo

spring-kotlin-gql-gae's Introduction

spring-kotlin-gql-gae

This is a sample skeleton of a backend app that was built using:

This app can be deployed on Google AppEngine Flex environment with a Google Cloud SQL(MySQL) database.

Getting Started

Running Locally

This section will cover the changes you will need to make to run the project locally.

Clone the project

After cloning the project open it using your favourite IDE. I recommend you InteliJ by Jetbrains

Install Mysql ( Mac OS) (๐Ÿšจ) Important Step

Install mysql on your machine using homebrew and create a database. I found this post very useful and with all of the information you will need to do that. Note: Remember to record the USER_NAME, PASSWORD and DATABASE_NAME you will create. You will need it later.

Installation TLDR; ( Do the following on your terminal)

  1. brew install mysql
  2. brew services start mysql
  3. mysql_secure_installation
  4. mysql.server start
  5. mysql -u root -p
  6. mysql> CREATE DATABASE <DATABASE_NAME>;
  7. mysql> CREATE USER '<USER>'@'localhost' IDENTIFIED BY '<PASSWORD>';
  8. mysql> GRANT ALL PRIVILEGES ON <DATABASE_NAME>.* TO '<USER>'@'localhost';
  9. mysql> exit

Configure the Database Connection on the project

  1. Open the project then the file **application.yml). The file is located at src/main/resources/application.yml
  2. Edit the spring configuration for the dev profile by adding the information about how to connect to your database
spring:
  config:
    activate:
      on-profile: dev
  r2dbc:
    initialization-mode: always
    url: r2dbc:mysql://localhost:3306/<DATABASE_NAME>
    username: <USER>
    password: <PASSWORD>

Run the application

You can run the application by executing the main function inside the SampleApplication.kt file or by executing the bootRun task that can be accessible through the tasks panel of your IDE if you are using InteliJ.

As it is mentioned on this page, after running the application you will get the following default routes:

Your newly created GraphQL server starts up with following preconfigured default routes:

/graphql - GraphQL server endpoint used for processing queries and mutations /subscriptions - GraphQL server endpoint used for processing subscriptions /sdl - Convenience endpoint that returns current schema in Schema Definition Language format /playground - Prisma Labs GraphQL Playground IDE endpoint

Go to playground and test

If all of your configurations are correct, you should now be able to have the GraphQL explorer by typing the following address on your browser: ***http://localhost:8080/playground.

This will open a Graphql IDE which will allow you to execute your GraphQL Operations and see your schema documentation.

Here are some of the things you can do with what we have setup now:

Create an Account

mutation CreateAccount($input: CreateAccountInput!) {
  createAccount(input: $input){
    account {
      firstName
      lastName
      email
      createdAt
      id
    }
  }
}

*Load an account by Id

query GetAccount($id: ID!) {
  account(id: $id) {
    firstName
    lastName
    email
    createdAt
  }
}

Building your own schema

To build your own schema I recommend you follow the documentation that can be found here. I found that part of the process very clear and as a result I see no need of repeating the steps here.

spring-kotlin-gql-gae's People

Contributors

realdm avatar danieljette 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.