8000 GitHub - permadiwibisono/area62-graphql: Indonesia Postal Code & Area in graphql
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

permadiwibisono/area62-graphql

Repository files navigation

area62-graphql

🇮🇩 Indonesia Postal Code & Area in graphql

Main Schemas:

  1. Country (example: INDONESIA)
  2. Province (example: SUMATERA BARAT)
  3. City (example: PADANG)
  4. DistrictOne as Kecamatan in Bahasa (example: PADANG UTARA)
  5. DistrictTwo as Kelurahan in Bahasa (example: LOLONG BELANTI)
  6. PostalCode (example: 25136)

Writing Queries:

{
  countryByCode(code: "ID") {
    code
    iso3
    name
    phoneCode
    emoji
  }
  provinces(filter: { name: { eq: "SUMATERA BARAT" } }) {
    id
    code
    name
    cities {
      id
      code
      name
      postal
    }
  }
}

The above GraphQL query will produce the following JSON response:

{
  "data": {
    "countryByCode": {
      "code": "ID",
      "iso3": "IDN",
      "name": "INDONESIA",
      "phoneCode": "62",
      "emoji": "🇮🇩"
    },
    "provinces": [
      {
        "id"<
8A1E
/span>: 3,
        "code": "13",
        "name": "SUMATERA BARAT",
        "cities": [
          {
            "id": 57,
            "code": "1301",
            "name": "KEPULAUAN MENTAWAI",
            "postal": "25700,25300"
          }
        ]
      }
    ]
  }
}

Run

Prerequisite

You may need install some of this:

  1. npm (Node version >= 16)
  2. PostgreSQL
  3. clone this repo :)

Setup ENV & install

cp .env.example .env
npm run install

Fill with valid values

Database Migration

with npx mikro-orm cli (recommended)

it will be store as .ts in migration table

npx mikro-orm migration:up

with ts-node db:migrate:ts (recommended)

it will be store as .ts in migration table

npm run db:migrate:ts

with db:migrate (in production use)

it will be store as .js in migration table

npm run db:migrate

Database Seed

npm run db:seed

Run server (with watch) for development

npm run dev

GraphQL playground in http://localhost:3000/graphql

Build

npm run build

Run server for production

npm start

Idea & Inspiration:

Big thanks for this repos and tutorials 🍻

  1. Countries GraphQL API
  2. INDONESIA POSTAL CODE & AREA
  3. TypeGraphql + MikroORM Example
  4. Graphql + MikroORM Example

About

Indonesia Postal Code & Area in graphql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0