/fagdag-swapi-graphql-api-java

An example graphql api for a Sonat fagdag written in Java with Spring Boot and GraphQL Java Kickstart

Primary LanguageJavaMIT LicenseMIT

Getting Started

This GraphQL API consumes SWAPI - The Star Wars API.

Running from command line

./gradlew bootRun
Common issues:

"Permission denied" on Mac, Ubuntu, etc. please run the following in terminal:

chmod +x gradlew

Install following to get started

Set enviorment variables per instructions for your operating system.

Playing with the API

Open these in your favourite browser after running the project.

Additional Links

These additional references should also help you:

Assignment 1

We will query the server with GraphQL queries

  1. Query for all films with fields title and producer
  2. Query for all films with fields title, openingcrawl and releaseDate
  3. Query for all films with fields title, vehicles (vehicles with at least two subfields: model and manufaturer).
  4. Query for all reviews
  5. Query for film with id 3
  6. Give a name to the query from assignment 5
  7. Change the value 3 with a variable

Assignment 2

We will fill in code to get the GraphQL API to work as it did in assignment 1.

Before we continue, please change branch

git branch del-2

Example queries

Add these queries to Playground after the project is up and running.

# All films with reviews
{
  films {
    episodeId
    title
    reviews {
      username
      diceThrow
    }
  }
}
#Film episode 4 with review
{
  film(id: 4) {
    episodeId,
    title,
    openingCrawl,
    director,
    producer,
    releaseDate,
    reviews {
      username
      diceThrow
    }
  }
}
#Film episode 4 with vehicle and review
{
  film(id: 4) {
    episodeId,
    title,
    openingCrawl,
    director,
    producer,
    releaseDate,
    vehicles {
      name
      passengers
      cargo_capacity
      maxAtmospheringSpeed
      }
    reviews {
      username
      diceThrow
    }
  }
}
# Vehicle with properties
{
  vehicle(id: 8) {
      name
      passengers
      cargo_capacity
      maxAtmospheringSpeed
  }
}
# Multation for creating a review
mutation {
  createReview(review: {id: 3, username: "SontUser123", diceThrow: 6}) {
    id
    username
    diceThrow
  }
}
# Play and describe a sound effect
{
audio {description}
}