Git Product home page Git Product logo

absinthe_subscription's Introduction

AbsintheSubscription

An example of creating GraphQL Subscriptions over WebSockets using Absinthe and Phoenix Channels.

Uses a simple GenServer for storing state.

Usage

Run the server using: mix phx.server

Open GraphiQL in your browser at http://localhost:4000/graphiql

Query Posts

{
  posts {
    id,
    title,
    body
  }
}

There should be one hardcoded by default.

Create a Post

mutation createPost {
  createPost(title: "another post", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sollicitudin, neque ac ultrices consectetur, eros sem viverra diam, at aliquam nunc mauris non arcu. Ut et sem a justo molestie tristique. Nunc consectetur orci felis, lacinia congue sem accumsan tempus. Sed sit amet risus nec est convallis tempor. Aenean facilisis tristique lacus quis eleifend. Sed elementum bibendum lectus, vel tristique quam sollicitudin in. Praesent sed venenatis nisi, sit amet maximus mauris. Maecenas sit amet pretium nibh, a pharetra lorem. Mauris sagittis erat vel finibus porttitor. Fusce convallis suscipit dolor, vitae tristique elit. Phasellus nisl est, efficitur eu vestibulum nec, commodo in dolor. Donec ac risus leo. Quisque quam velit, sodales non sem in, ullamcorper semper tortor. Quisque dignissim lectus eu ligula dapibus, et hendrerit nisi ultrices.") {
    id
  }
]

Create a Subscription

Run this inside of GraphiQL

subscription {
  postCreated {
    id,
    title,
    body
  }
}

Now in a separate window create more posts. Each time a post is created you will see it in the subscription query.

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.