Code Monkey home page Code Monkey logo

poc-postgraphile-forum's Introduction

POC Postgraphile - forum example

Roadmap:

$ ./scripts/start-pg-and-wait-starting.sh
$ ./scripts/seed.sh
$ ./scripts/fixtures.sh
$ docker-compose up -d

Urls:

Query

{
  posts {
    nodes {
      id
      headline
      body
      summary
      authorId
    }
  }
}

Authenticate

mutation {
  authenticate(input: {email: "[email protected]", password: "password"}) {
    clientMutationId
    jwtToken
  }
}

Result:

{
  "data": {
    "authenticate": {
      "clientMutationId": null,
      "jwtToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiZm9ydW1fZXhhbXBsZV9wZXJzb24iLCJwZXJzb25faWQiOiIxZGU5Yzk4Ny0wOGFiLTMyZmUtZTIxOC04OWMxMjRjZDAwMDEiLCJpYXQiOjE1NjQzMTk3ODgsImV4cCI6MTU2NDQwNjE4OCwiYXVkIjoicG9zdGdyYXBoaWxlIiwiaXNzIjoicG9zdGdyYXBoaWxlIn0.SxpP_2s8sG1-3Qc8aV9N1-A99oBPoqv1W_8BfKoYBtY"
    }
  }
}

Use JWT Token in header

{
"Authorization": "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiZm9ydW1fZXhhbXBsZV9wZXJzb24iLCJwZXJzb25faWQiOiIxZGU5Yzk4Ny0wOGFiLTMyZmUtZTIxOC04OWMxMjRjZDAwMDEiLCJpYXQiOjE1NjQzMTk3ODgsImV4cCI6MTU2NDQwNjE4OCwiYXVkIjoicG9zdGdyYXBoaWxlIiwiaXNzIjoicG9zdGdyYXBoaWxlIn0.SxpP_2s8sG1-3Qc8aV9N1-A99oBPoqv1W_8BfKoYBtY"
}

Create a post

mutation {
  createPost(input: {post: {headline: "headline 1", authorId: "1de9c987-08ab-32fe-e218-89c124cd0001", body: "body1", topic: DISCUSSION}}) {
    clientMutationId
    post {
      id
      author {
        firstName
        id
      }
    }
  }
}

Result:

{
  "data": {
    "createPost": {
      "clientMutationId": null,
      "post": {
        "id": "b6799d54-ac68-4170-9b62-3536921bb164",
        "author": {
          "firstName": "first_name001",
          "id": "1de9c987-08ab-32fe-e218-89c124cd0001"
        }
      }
    }
  }
}

Test worker

$ ./scripts/enter-in-pg.sh
poc-forum=# SELECT graphile_worker.add_job('hello', json_build_object('name', 'Bobby Tables'));
                                                                                        add_job
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 (1,ec43b4ee-f950-402e-8fa4-b223388c00bf,hello,"{""name"" : ""Bobby Tables""}",0,"2019-08-09 11:23:56.034334+00",0,25,,"2019-08-09 11:23:56.034334+00","2019-08-09 11:23:56.034334+00")
(1 row)

See graphile-worker logs:

$ docker-compose logs -f graphile-worker
graphile-worker_1  | Worker connected and looking for jobs... (task names: 'hello')
graphile-worker_1  | Hello, Bobby Tables
graphile-worker_1  | Completed task 1 (hello) with success (0.53ms)

poc-postgraphile-forum's People

Contributors

stephane-klein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.