Skip to content

Latest commit

 

History

History
186 lines (154 loc) · 2.22 KB

README.md

File metadata and controls

186 lines (154 loc) · 2.22 KB

GraphQL + Express.js Star Wars API

Screenshot

DEMO

demo.mov

SWAPI REST API

Star Wars REST API at http://swapi.co/ to demonstrate a GraphQL Server running on Express.

Installation

NPM Modules

The following NPM modules are required in package.json:

  • express
  • express-graphql
  • graphql
  • axios
  • dataloader
  • nodemon

Install with:

npm install

Run the project

npm start

Running GraphQL Queries

You can run these queries within GraphiQL

localhost: 3000 / graphql;

Find a film by Id

query {
  film (id:"1") {
    title,
    director
  }
}

Find a vehicle by Id

query {
  vehicle(id: "8") {
    name
  }
}

Find a starship by Id

query {
  starship(id:"5") {
    name
  }
}

Find species by Id

query {
  species(id:"1") {
    name
  }
}

Find planet by Id

query {
	planet(id: "1") {
    name
  }
}

Find character by Id

query {
  character (id: "1") {
    name,
    height,
    mass,
    hair_color,
    skin_color,
    eye_color,
    birth_year,
    gender,
    homeworld {
      name
      rotation_period
      orbital_period
      diameter
      climate
      gravity
      terrain
      surface_water
      population
      residents {
        name
        birth_year
        gender
      }
      created
      edited
    },
    films {
      title
      director
    },
    species {
      name,
      classification,
      designation,
      language,
      people {
        name
        birth_year
        gender
      },
      films {
        title
        director
      }
    }
    vehicles{
      name,
      model,
      cost_in_credits,
      length,
      crew,
      passengers,
      vehicle_class,
      pilots {
        name
      },
      films {
        title
      }
    }
    starships{
      name,
      model,
      cost_in_credits,
      length,
      crew,
      passengers,
      hyperdrive_rating,
      starship_class,
      pilots {
        name
      },
      films {
        title
      }
    }
    created,
    edited
  }
}