Git Product home page Git Product logo

graphql-pokeapi's Introduction

๐Ÿ”ด The Unofficial GraphQL for PokeAPI

PokeAPI

PRs Welcome Wesite Up Actions

Playground Screenshot

Homepage

https://graphql-pokeapi.vercel.app

Endpoint

Playground

https://graphql-pokeapi.vercel.app/api/graphql

Applications

If you are using graphql-pokeapi, you can add your apps in our awesome-list.md

Sending Request Example

Queries

Query Desc Variables
abilities Get list of abilities
ability Get detail of ability ability
berries Get list of berries
berry Get detail of berry berry
eggGroups Get list of egg groups
eggGroup Get detail of egg group eggGroup
encounterMethods Get list of encounterMethods
encounterMethod Get detail of encounterMethod encounterMethod
evolutionChains Get list of evolutionChains
evolutionChain Get detail of evolutionChains id
evolutionTriggers Get list of evolutionTriggers
evolutionTrigger Get detail of evolutionTrigger name
genders Get list of genders
gender Get detail of gender gender
growthRates Get list of growth rates
growthRate Get detail of growth rate growthRate
locations Get list of locations
location Get detail of location location
moves Get list of moves
move Get detail of move move
natures Get list of natures
nature Get detail of nature nature
pokemons Get list of pokemons limit, offset
pokemon Get detail info of pokemon name
regions Get list of regions
region Get detail of region region
species Get list of species
types Get list of types

Query Examples

pokemons

Desc: Get list of pokemons

Sample Query

query pokemons($limit: Int, $offset: Int) {
  pokemons(limit: $limit, offset: $offset) {
    count
    next
    previous
    status
    message
    results {
      url
      name
      image
    }
  }
}

Sample Variables

{
  "limit": 2,
  "offset": 1
}

Sample Result

{
  "data": {
    "pokemons": {
      "count": 964,
      "next": "https://pokeapi.co/api/v2/pokemon/?offset=3&limit=3",
      "previous": null,
      "results": [
        {
          "url": "https://pokeapi.co/api/v2/pokemon/1/",
          "name": "bulbasaur",
          "image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png"
        },
        {
          "url": "https://pokeapi.co/api/v2/pokemon/2/",
          "name": "ivysaur",
          "image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/2.png"
        },
        {
          "url": "https://pokeapi.co/api/v2/pokemon/3/",
          "name": "venusaur",
          "image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/3.png"
        }
      ],
      "status": true,
      "message": ""
    }
  }
}

pokemon

Desc: Get detail info of pokemon

Sample Query

query pokemon($name: String!) {
  pokemon(name: $name) {
    id
    name
    abilities {
      ability {
        name
      }
    }
    moves {
      move {
        name
      }
    }
    types {
      type {
        name
      }
    }
    message
    status
  }
}

Sample Variables

{
  "name": "ditto"
}

Sample Result

{
  "data": {
    "pokemon": {
      "id": 132,
      "name": "ditto",
      "abilities": [
        {
          "ability": {
            "name": "imposter"
          }
        },
        {
          "ability": {
            "name": "limber"
          }
        }
      ],
      "moves": [
        {
          "move": {
            "name": "transform"
          }
        }
      ],
      "types": [
        {
          "type": {
            "name": "normal"
          }
        }
      ],
      "message": "",
      "status": true
    }
  }
}

Credits


Copyright ยฉ By Irfan Maulana

graphql-pokeapi's People

Contributors

adhafajri avatar andarasophan avatar cholazzzb avatar dependabot[bot] avatar derida23 avatar fadilaharifki avatar ferdianatmadiputra avatar gabriel-brito avatar haris0 avatar hurifajri avatar irfan-maulana-tkp avatar ivqonsanada avatar kodiakhq[bot] avatar mazipan avatar snyk-bot avatar streeterxs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

graphql-pokeapi's Issues

Docs: sample sending request

Need to add example in how to make a request, it should consist of:

  • Using Fetch
  • Using Apollo
  • Using POST method
  • Using GET method

How to get more info from pokemons query

First thanks for this awesome api ๐Ÿ‘ been using it in one of my side projects.

When I use pokemons query I get an URL to pokeapi rest service I wanted info that comes from there, how I'm supposed to get this info using apollo client?

import { gql, useQuery } from '@apollo/client';
import React from 'react';
import { ListItem, UnorderedList } from './styles';

const GET_POKEMON_DETAILS = gql`
    {
        pokemons(limit: 150, offset: 0) {
            results {
                url
                name
                image
            }
        }
    }
`;

export const Home: React.FC = () => {
    const { loading, error, data } = useQuery(GET_POKEMON_DETAILS);
    if (loading) return <p>Loading...</p>;
    if (error) return <p>Error :(</p>;

    return (
        <UnorderedList>
            {data.pokemons.results.map((x: any) => (
                <ListItem key={x.name}>
                    <p>{x.name}</p>
                    <img src={x.image} alt={x.name} />
                </ListItem>
            ))}
        </UnorderedList>
    );
};

export default Home;

This is what I been doing on my codebase.

What I wanted is a way to do

const GET_POKEMON_DETAILS = gql`
    {
        pokemons(limit: 150, offset: 0) {
            results {
                url
                name
                image
                types
               stats
               ...
            }
        }
    }
`;

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.