Giter VIP home page Giter VIP logo

pactflow-example-provider-java-graphql's Introduction

Example Java GraphQL Provider

Build

Can I deploy Status

Pact Status (latest pact)

Pact Status (prod/prod pact)

This is an example of a Java Spring Boot GraphQL provider that uses Pact, PactFlow and GitHub Actions to ensure that it is compatible with the expectations its consumers have of it.

The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy.

It is using a public tenant on PactFlow, which you can access here using the credentials dXfltyFMgNOFZAxr8io9wJ37iUpY42M/O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1.

Project Phases

The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy.

  • Test
    • Run tests (including the pact tests that generate the contract)
    • Publish pacts, tagging the consumer version with the name of the current branch
    • Check if we are safe to deploy to prod (ie. has the pact content been successfully verified)
  • Deploy (only from main)
    • Deploy app (just pretend for the purposes of this example!)
    • Tag the deployed consumer version as 'prod'

Dependencies

  • Docker
  • A PactFlow account
  • A read/write API Token from your PactFlow account
  • Java 19+ installed
  • A linux based environment (e.g. MacOSX, Linux, Windows Subsystem for Linux)

Usage

See the PactFlow CI/CD Workshop.

The below commands are designed for a Linux/OSX environment, please translate for use on Windows/PowerShell as necessary:

Please ensure the following environment variables have been exported in the process that you run the tests (generally a terminal):

export PACT_BROKER_TOKEN=<your pactflow read/write token here>
export PACT_BROKER_BASE_URL=https://<your pactflow subdomain>.pactflow.io
export PACT_BROKER_HOST=<your pactflow subdomain>.pactflow.io

You can run the tests locally with:

make test

Simulating CI

Usually, you would integrate this into a real CI system (such as Buildkite/Jenkins/CircleCI etc., or GitHub Actions as this repository is built against).

You can simulate a CI process with the following command:

make fake_ci

Graphiql

Once you start the app (./gradlew bootRun) you can view the Graphiql interface and interact with the GraphQL server at http://localhost:8080/graphiql

Example query:

{
  product(id: 1) {
    id
    name
    type
  }
}

pactflow-example-provider-java-graphql's People

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.