All Projects → bahmutov → todo-graphql-example

bahmutov / todo-graphql-example

Licence: other
Example Todo app on top of json-graphql-server

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to todo-graphql-example

cypress-example-docker-compose
Example running Cypress tests against Apache server via docker-compose
Stars: ✭ 106 (+430%)
Mutual labels:  example, cypress, cypress-io
cypress-example-circleci-orb
Demo of using the Cypress CircleCI Orb
Stars: ✭ 26 (+30%)
Mutual labels:  example, cypress, cypress-io
vue-vuex-todomvc
Example TodoMVC Vue.js app with Vuex store and server backend via REST
Stars: ✭ 41 (+105%)
Mutual labels:  example, todomvc, cypress-example
cypress-example-docker-circle-workflows
Cypress + Docker + CircleCI Workflows = ❤️
Stars: ✭ 29 (+45%)
Mutual labels:  cypress, cypress-io
cypress-example-todomvc-redux
Example TodoMVC application with full code coverage
Stars: ✭ 43 (+115%)
Mutual labels:  cypress, cypress-example
snapshot
Adds value / object / DOM element snapshot testing support to Cypress test runner
Stars: ✭ 114 (+470%)
Mutual labels:  cypress, cypress-io
svelte-pwa-now
A PWA ready Svelte v3.0 starter template with Tailwind, Now integration and optional Typescript suppot
Stars: ✭ 138 (+590%)
Mutual labels:  cypress, cypress-io
local-cypress
Use Cypress without global objects
Stars: ✭ 19 (-5%)
Mutual labels:  cypress, cypress-example
TLE5012-Magnetic-Angle-Sensor
This repository includes an library for Arduino for the TLE5012 Magnetic Angle Sensor with SSC interface.
Stars: ✭ 37 (+85%)
Mutual labels:  cypress, cypress-io
cypress-browserify-preprocessor
Cypress preprocessor for bundling JavaScript via browserify
Stars: ✭ 23 (+15%)
Mutual labels:  cypress, cypress-io
instrument-cra
Little module for CRA applications to instrument code without ejecting react-scripts
Stars: ✭ 61 (+205%)
Mutual labels:  cypress, cypress-io
cypress-gh-action-example
Example running Cypress tests inside GitHub Action
Stars: ✭ 29 (+45%)
Mutual labels:  cypress, cypress-example
cypress-hyperapp-unit-test
Unit test Hyperapp components using Cypress
Stars: ✭ 26 (+30%)
Mutual labels:  cypress, cypress-io
cypress-retry
Retry just the failed Cypress.io tests using Cypress module API and AST rewriting
Stars: ✭ 16 (-20%)
Mutual labels:  cypress, cypress-io
cypress-xpath
Adds XPath command to Cypress test runner
Stars: ✭ 145 (+625%)
Mutual labels:  cypress, cypress-io
cypress-upload-file-post-form
Solution for two Cypress testing use-cases I came across with: perform a direct http FORM request to the server containing a file and other parameters and upload a file into a form before submission
Stars: ✭ 59 (+195%)
Mutual labels:  cypress, cypress-io
cypress-get-it
Get elements by data attribute by creating a Cy command on the fly
Stars: ✭ 23 (+15%)
Mutual labels:  cypress, cypress-io
cypress-watch-and-reload
Reloads Cypress when one of the watched files changes
Stars: ✭ 46 (+130%)
Mutual labels:  cypress, cypress-io
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+8800%)
Mutual labels:  example, todomvc
Todomvc Ddd Cqrs Eventsourcing
Implementation of basic Todo app via tastejs/todomvc in C#/Typescript with eventsourcing, cqrs, and domain driven design
Stars: ✭ 134 (+570%)
Mutual labels:  example, todomvc

todo-graphql-example cypress version

ci status badges status tags renovate-app badge todo-graphql-example CircleCI

Blog posts

Read Smart GraphQL Stubbing in Cypress. Note that with the addition of cy.intercept all extra hacks became unnecessary.

Videos

Cypress tests

All tests are in the cypress/integration folder.

By mocking network calls using cy.intercept see the intercept-spec.js file.

Spec client-spec.js is testing making individual GraphQL calls using app's own client.

Spec ui-spec.js has simple tests that do not depend on the network, and thus are hard to write.

We can use cy.request command to make GraphQL requests ourselves, see the request-spec.js file.

We can stub the initial items load using a fixture file. See the spec file fixture-spec.js.

We delete all items in the delete-spec.js test. First we query all todo items, then delete them one by one.

We can import the list of items from a fixture file cypress/fixtures/three.json and create a dynamic test for each item, see the spec file dynamic-spec.js.

App

Start server with npm start. You can find GraphQL playground at http://localhost:3000

App in action

Example asking for all todos

query {
  allTodos {
    id,
    title,
    completed
  }
}

Response

{
  "data": {
    "allTodos": [
      {
        "id": "1",
        "title": "do something",
        "completed": false
      },
      {
        "id": "2",
        "title": "another",
        "completed": false
      }
    ]
  }
}

Example creating new todo object

mutation {
  createTodo(id: 2, title: "another", completed: false) {
    id
  }
}

Response

{
  "data": {
    "createTodo": {
      "id": "2"
    }
  }
}

Example asking for a single todo (notice id argument)

query {
  Todo(id: 2) {
    id,
    title,
    completed
  }
}

Response

{
  "data": {
    "Todo": {
      "id": "2",
      "title": "another",
      "completed": false
    }
  }
}

Development

Backend is json-graphql-server. Front-end React code is in src folder, modeled after Getting Started With React And GraphQL post.

To start the applications and open Cypress

$ npm run dev
# starts the API, starts the web application
# when the application responds
# opens Cypress test runner

To start the application and run headless Cypress tests

$ npm run local

Types

Look at cypress/jsconfig.json that loads all 3rd party types, and includes the link to cypress/support/index.d.ts where I describe the type for custom command cy.createTodos defined in cypress/support/index.js.

About me

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].