All Projects → favware → graphql-pokemon

favware / graphql-pokemon

Licence: MIT license
Extensive Pokémon GraphQL API

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to graphql-pokemon

react-relay-pokemon
Use React & Relay as your Pokedex!
Stars: ✭ 88 (+8.64%)
Mutual labels:  pokemon, graphql-pokemon
showdown-battle-bot
Socket Battle Bot for Pokemon Showdown (http://pokemonshowdown.com/)
Stars: ✭ 19 (-76.54%)
Mutual labels:  pokemon, showdown
hoodie-notes
A Markdown notebook built with React and Hoodie
Stars: ✭ 17 (-79.01%)
Mutual labels:  showdown
stylegan-pokemon
Generating Pokemon cards using a mixture of StyleGAN and RNN to create beautiful & vibrant cards ready for battle!
Stars: ✭ 47 (-41.98%)
Mutual labels:  pokemon
pokemon-randomizer
A Pokémon Rom randomizer tool written in Zig
Stars: ✭ 12 (-85.19%)
Mutual labels:  pokemon
newbark-unity
🌳 A proof-of-concept Pokémon-style Retro RPG game framework created with Unity 🔥🌿💧⚡️
Stars: ✭ 139 (+71.6%)
Mutual labels:  pokemon
angular2-pokedex
A Pokedex built on Angular with AoT, Tree Shaking, Rollup and TypeScript
Stars: ✭ 34 (-58.02%)
Mutual labels:  pokemon
porybox
Porybox is a platform that allows you to display your Pokémon collection.
Stars: ✭ 38 (-53.09%)
Mutual labels:  pokemon
PokemonRNGGuides
A repository of Pokemon RNG abuse guides
Stars: ✭ 62 (-23.46%)
Mutual labels:  pokemon
POGOProtos
A central repository for all proto files of PokémonGO.
Stars: ✭ 136 (+67.9%)
Mutual labels:  pokemon
showdown-katex
Math typesetting for showdown
Stars: ✭ 32 (-60.49%)
Mutual labels:  showdown
pokecss-media
Compilation of images of all Pokémon 3D sprites, icons and items. This is a fork of a now removed respository.
Stars: ✭ 21 (-74.07%)
Mutual labels:  pokemon
PokemonChineseTranslationRevise
《宝可梦》第四、第五世代汉化修正
Stars: ✭ 51 (-37.04%)
Mutual labels:  pokemon
ngx-showdown
Angular (>=2) integration for Showdown
Stars: ✭ 16 (-80.25%)
Mutual labels:  showdown
gitemon
👾 Gotta Catch 'Em All!
Stars: ✭ 15 (-81.48%)
Mutual labels:  pokemon
online-randomizer
Fresh new playthroughs!
Stars: ✭ 23 (-71.6%)
Mutual labels:  pokemon
pokemon-game
Pokemon game — Get 'em all
Stars: ✭ 55 (-32.1%)
Mutual labels:  pokemon
pokeStore
pokeStore寶可商店 搬移至Vue CLI 3 引入vuex
Stars: ✭ 28 (-65.43%)
Mutual labels:  pokemon
pokenode-ts
A lightweight Node.js wrapper for the PokéAPI with built-in types.
Stars: ✭ 102 (+25.93%)
Mutual labels:  pokemon
pokemon-icons
Fan art inspired by Pokémon
Stars: ✭ 85 (+4.94%)
Mutual labels:  pokemon
ArchAngel

GraphQL-Pokemon

Extensive Pokémon GraphQL API!

GitHub

Continuous Deployment Continuous Integration Automatic Data Update npm

Support Server


Table of Contents


Query for Pokémon data using GraphQL

Key Features

  • Fully generated client-side TypeScript typings published to
  • Docker images of the API for private hosting published to
  • Provides information about various assets in Pokémon
    • Pokédex
    • Items
    • Abilities
    • Moves
    • Learnsets
    • Type matchups

Installation

Note: This is only needed if you are writing TypeScript, or if you're using a GraphQL schema validator. If you're using neither of these, you do not need to install this package. The package does NOT include the actual API, ONLY type information.

Install client side typings from yarn or npm:

yarn add -D @favware/graphql-pokemon
npm install -D @favware/graphql-pokemon

API Documentation

For the full documentation of the deployed version please see the GraphQL Playground on the API.

Usage

These examples are written as based on TypeScript. For JavaScript simply change out the imports to require syntax and remove any type information.

Using Fetch

import type { Query } from '@favware/graphql-pokemon';

interface GraphQLPokemonResponse<K extends keyof Omit<Query, '__typename'>> {
  data: Record<K, Omit<Query[K], '__typename'>>;
}

fetch('https://graphqlpokemon.favware.tech/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    query: `
      {
        getPokemon(pokemon: dragonite) {
            sprite
            num
            species
            color
        }
      }
    `
  })
})
  .then((res) => res.json() as Promise<GraphQLPokemonResponse<'getPokemon'>>)
  .then((json) => console.log(json.data));

Using Apollo Boost

note: for a working example see dexa

import type { Query, QueryGetFuzzyPokemonArgs } from '@favware/graphql-pokemon';
import ApolloClient from 'apollo-boost';
import fetch from 'cross-fetch';
import gql from 'graphql-tag';

type GraphQLPokemonResponse<K extends keyof Omit<Query, '__typename'>> = Record<K, Omit<Query[K], '__typename'>>;

const getFuzzyPokemon = gql`
  query getFuzzyPokemon($pokemon: String!) {
    getFuzzyPokemon(pokemon: $pokemon) {
      sprite
      num
      species
      color
    }
  }
`;

const apolloClient = new ApolloClient({
  uri: 'https://graphqlpokemon.favware.tech/',
  fetch
});

const {
  data: { getFuzzyPokemon: pokemonData }
} = await apolloClient.query<GraphQLPokemonResponse<'getFuzzyPokemon'>, QueryGetFuzzyPokemonArgs>({
  query: getFuzzyPokemon,
  variables: { pokemon: 'dragonite' }
});

console.log(pokemonData);

Using Apollo Client React

// ApolloClient setup
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';

// Instantiate required constructor fields
const cache = new InMemoryCache();
const link = new HttpLink({
  uri: 'https://graphqlpokemon.favware.tech/'
});

export const client = new ApolloClient({
  // Provide required constructor fields
  cache: cache,
  link: link,

  // Provide some optional constructor fields
  name: 'graphql-pokemon-client',
  version: '1.0',
  queryDeduplication: false,
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'cache-and-network'
    }
  }
});
// Component
import React from 'react';
import gql from 'graphql-tag';
import { useQuery } from '@apollo/react-hooks';
import type { Query } from '@favware/graphql-pokemon';
import { client } from './ApolloClient';

interface GraphQLPokemonResponse<K extends keyof Omit<Query, '__typename'>> {
  data: Record<K, Omit<Query[K], '__typename'>>;
}

const GET_POKEMON_DETAILS = gql`
  {
    getPokemon(pokemon: dragonite) {
      sprite
      num
      species
      color
    }
  }
`;

export const Pokemon: React.FC = () => {
  const { loading, error, data } = useQuery<GraphQLPokemonResponse<'getPokemon'>>(GET_POKEMON_DETAILS, {
    client: client
  });

  if (loading) return 'Loading...';
  if (error) return `Error! ${error.message}`;

  return <div> Insert how you want to display the data here </div>;
};

Meta

License

Copyright © 2019, Favware. Released under the MIT License.

Buy us some doughnuts

Favware projects is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!

We accept donations through Ko-fi, Paypal, Patreon, GitHub Sponsorships, and various crypto currencies. You can use the buttons below to donate through your method of choice.

Donate With Address
Ko-fi Click Here
Patreon Click Here
PayPal Click Here
GitHub Sponsors Click Here
Bitcoin 1E643TNif2MTh75rugepmXuq35Tck4TnE5
Ethereum 0xF653F666903cd8739030D2721bF01095896F5D6E
LiteCoin LZHvBkaJqKJRa8N7Dyu41Jd1PDBAofCik6

Contributors

Thanks goes to these wonderful people (emoji key):


Jeroen Claassens

🐛 💻 🎨 💡 🤔 🚇 🚧 📦 📆 👀 💬 🛡️ ⚠️ 📓

Favware Bot

💻 🚧

Imgbot

🚧

dependabot-preview[bot]

🚧

depfu[bot]

🚧

Kaoru

💻 🚧

Emily

💻

Ed L

💻

nandhagk

💻

dependabot[bot]

🚧

github-actions[bot]

🚧

allcontributors[bot]

📖

Kaname

⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].