Giter VIP home page Giter VIP logo

subgraph-template-java-dgs-unofficial's Introduction

Java DGS GraphQL Subgraph

Deploy on Railway

This is an example application template that can be used to create Federated GraphQL subgraph using DGS Framework.

This example application implements following GraphQL schema:

directive @contact(
    "Contact title of the subgraph owner"
    name: String!
    "URL where the subgraph's owner can be reached"
    url: String
    "Other relevant notes can be included here; supports markdown links"
    description: String
) on SCHEMA

schema
@contact(
    name: "FooBar Server Team"
    url: "https://myteam.slack.com/archives/teams-chat-room-url"
    description: "send urgent issues to [#oncall](https://yourteam.slack.com/archives/oncall)."
)
@link(
    url: "https://specs.apollo.dev/federation/v2.0",
    import: ["@key"]
) {
    query: Query
}

type Query {
    shows(titleFilter: String): [Show]
}

type Show @key(fields: "id") {
    id: ID!
    title: String
    releaseYear: Int
}

Build

This project uses Gradle and requires Java 17+ runtime. In order to build the project locally (which will also execute all the tests), simply run the build task.

./gradlew clean build

NOTE: in order to ensure you use the right version of Gradle we highly recommend to use the provided wrapper script

Continuous Integration

This project comes with some example build actions that will trigger on PR requests and commits to the main branch.

Run

To start the GraphQL server:

  • Run Application.java directly from your IDE
  • Alternatively you can also run the Spring Boot plugin directly from the command line
./gradlew bootRun

Once the app has started you can explore the example schema by opening the GraphiQL endpoint at http://localhost:8080/graphiql begin developing your supergraph with rover dev --url http://localhost:8080/graphql --name my-sugraph.

Apollo Studio Integration

  1. Set these secrets in GitHub Actions:
    1. APOLLO_KEY: An Apollo Studio API key for the supergraph to enable schema checks and publishing of the subgraph.
    2. APOLLO_GRAPH_REF: The name of the supergraph in Apollo Studio.
    3. PRODUCTION_URL: The URL of the deployed subgraph that the supergraph gateway will route to.
  2. Set SUBGRAPH_NAME in .github/workflows/checks.yaml and .github/workflows/deploy.yaml
  3. Remove the if: false lines from .github/workflows/checks.yaml and .github/workflows/deploy.yaml to enable schema checks and publishing.
  4. Write your custom deploy logic in .github/workflows/deploy.yaml.
  5. Send the Router-Authorization header from your Cloud router and set the ROUTER_SECRET environment variable wherever you deploy this to.

Additional Resources

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.