Giter Site home page Giter Site logo

iansu / apollo-schema-check-action Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 3.0 3.34 MB

A GitHub Action to run a schema check with Apollo Studio and post the results as a comment on a Pull Request

License: MIT License

TypeScript 96.69% JavaScript 3.09% Shell 0.22%
actions apollo github-actions graphql

apollo-schema-check-action's Introduction

About Me

๐Ÿ‘‹ My name is Ian, I live in Calgary, Canada ๐Ÿ‡จ๐Ÿ‡ฆ and I work as a Principal Software Engineer at Neo Financial where we're building digital banking products for Canadians.

Iโ€™m a member of the Node.js team where I primarily contribute as part of the Tooling Working Group. I also work on a number of other open source projects, mostly in the JavaScript and TypeScript ecosystems.

If you are interested in supporting any of my open source work I encourage you to sponsor me on GitHub.

Speaking

I've spoken at conferences and meetups and been a guest on podcasts and livestreams. I have a list of past appearances, along with recordings from most of them, on my personal site. If you'd like me to speak at an event or be a guest on a podcast, livestream or panel please get in touch.

Goals for 2023

Projects

Want to know what I'm working on this month? Take a look at my list of current projects.

Personal Open Source Projects

These are projects I work on myself in my free time.

Neo Financial Open Source Projects

These are projects open sourced by my company that I work on and help maintain along with other members of my team.

  • awsx - An AWS CLI profile switcher with MFA and Assume Role support
  • config-dug - A config loader with support for AWS Secrets Manager
  • graphql-date-scalars - GraphQL Scalars for Date, DateTime, and Time values
  • serverless-plugin-neo - Serverless Framework plugin that compiles TypeScript code and bundles dependencies with node-file-trace
  • ticket-check-action - A GitHub Action that ensures all your PRs include a ticket reference in the title
  • ccscan - A tool to scan files for credit card numbers
  • eslint-config-neo - Our ESLint config with support for JavaScript and TypeScript

Get in Touch

Want to discuss any of my open source projects, or something else? Send me a direct message on Twitter.

apollo-schema-check-action's People

Contributors

andresrodh avatar comp615 avatar dependabot[bot] avatar iansu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

apollo-schema-check-action's Issues

Issue with running iansu/apollo-schema-check-action@v2 in GitHub Actions workflow

Description:

I am currently facing an issue while trying to run the iansu/apollo-schema-check-action@v2 in my GitHub Actions workflow. The action is intended to check my GraphQL schema against the specified Apollo graph, but it is encountering an error during execution.

Workflow Configuration:

Here is the relevant portion of the GitHub Actions workflow file where I've implemented the iansu/apollo-schema-check-action@v2:

name: Schema Check

on:
  pull_request:
    types: [opened, reopened, edited, synchronize]
    branches: [master, develop, staging, 'release/*']

jobs:
  check_schema:
    name: Check Schema
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Customer API check
        uses: iansu/apollo-schema-check-action@v2

        with:
          title: GRAPH_TITLE
          graph: GRAPH_ID
          variant: GRAPH_VARIANT
          localSchemaFile: ./backend/backend/src/backend-api/generated/backend-schema.graphql
          alwaysComment: true
          failOnError: true
          validationPeriod: P2W
          key: ${{ secrets.APOLLO_KEY }}

        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Error Message:

The specific error message I am encountering when the action runs is as follows:

Error: {}

Expected Behavior:

I expected the iansu/apollo-schema-check-action@v2 to successfully check the GraphQL schema against the specified Apollo graph and provide relevant feedback via comments on pull requests or commits. Additionally, if any schema validation errors are found, the action should fail the workflow due to failOnError: true and show an error message that helps to fix it.

Troubleshooting Attempted:

  1. I verified that the GraphQL schema file backend-schema.graphql is present in the correct location relative to the workflow file.

  2. I made sure that the GitHub Secrets (APOLLO_KEY and GITHUB_TOKEN) are set up correctly and contain the appropriate values.

Request for Assistance:

I kindly request assistance in resolving the issue with the iansu/apollo-schema-check-action@v2 so that I can successfully validate my GraphQL schema against the specified Apollo graph in my GitHub Actions workflow.

Thank you for your help.

Composition / Invalid Schema Errors are incorrectly shown as passes

Describe the bug
If you upload a schema which is not valid (i.e. does not compile), then the check in Apollo Studio will fail, but the GHA will pass with no indication. I encountered this in particular from federation version upgrade errors on Apollo.

This only occurs if alwaysComment is not set.

To Reproduce
Steps to reproduce the behavior:

  1. Change your schema by setting a scalar to a non-sensical name for instance
  2. Run the action against the new schema
  3. Observe the check passes.
  4. But look in Apollo studio and notice the check fails with build errors

Expected behavior
The GHA should fail any time the Apollo Studio check fails. Otherwise it's possible for silent breakages.

Additional context
I will provide a PR for this shortly!

Invalid Timestamp returned for check in some cases

Describe the bug
Using this action, sometimes the checks are not correctly run
image

To Reproduce
Steps to reproduce the behavior:

  1. Make a change using the job below
  2. Check results in Apollo. Sometimes nothing is returned and the date range is shown as invalid

Environment

jobs:
  check_schema:
    name: check schema
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v2
      - name: Apollo Schema check
        uses: iansu/apollo-schema-check-action@v2
        with:
          graph: [[REDACTED]]
          localSchemaFile: 'server/graphql/schema.graphql'
          serviceName: [[REDACTED]]
          validationPeriod: P1W
          key: ${{ secrets.APOLLO_KEY }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Additional context
Continuing to look at this and see if there's any commonalities. Seems likely it might be an issue on the Apollo side of things since I don't know what would have changed here

Check fails with "Graph ... is not a composition variant"

Thanks for making this handy action. I had it working fine for a several months, but sometime in the past week the checks have begun to fail on every run with an error that looks like the following. (My last successful run was on 3 Jan 2023.) I haven't changed anything in my GitHub workflow or in the project config in Apollo Studio.

Maybe something has changed on the Apollo side that is breaking this action?

{
  "response": {
    "errors": [
      {
        "message": "Graph my-graph@prod is not a composition variant.",
        "extensions": {
          "code": "INTERNAL_SERVER_ERROR",
          "serviceName": "registry"
        }
      }
    ],
    "data": {
      "service": null
    },
    "status": 200,
    "headers": {}
  },
  "request": {
    "query": "\n    mutation SubgraphCheckMutation(\n      $graph: ID!\n      $variant: String!\n      $serviceName: String!\n      $proposedSchema: PartialSchemaInput!\n      $gitContext: GitContextInput!\n      $queryParameters: HistoricQueryParameters!\n    ) {\n      service(id: $graph) {\n        checkPartialSchema(\n          graphVariant: $variant\n          implementingServiceName: $serviceName\n          partialSchema: $proposedSchema\n          gitContext: $gitContext\n          historicParameters: $queryParameters\n        ) {\n          compositionValidationResult {\n            compositionSuccess\n            errors {\n              message\n              code\n              locations {\n                line\n                column\n              }\n            }\n          }\n          checkSchemaResult {\n            diffToPrevious {\n              severity\n              numberOfCheckedOperations\n              numberOfAffectedOperations\n              changes {\n                severity\n                code\n                description\n              }\n            }\n            targetUrl\n          }\n        }\n      }\n    }\n  ",
    "variables": {
      "config": "",
      "graph": "my-graph",
      "variant": "prod",
      "endpoint": "",
      "headers": "",
      "apolloKey": "***",
      "localSchemaFile": "./schema.graphql",
      "queryCountThreshold": "",
      "queryCountThresholdPercentage": "",
      "serviceName": "api",
      "validationPeriod": "P1W",
      "queryParameters": {
        "from": "604800"
      },
      "proposedSchema": {
        "sdl": "...SNIPPED..."
      },
      "gitContext": {
        "branch": "my-branch",
        "commit": "f023dc73242f4783d686732cdac666824bdd81b3",
        "committer": "sgarner",
        "message": "Merge 34f1e656ede5d3b56c291d93f4b38cbdae53e730 into 212b0831269d1098486146328eb03aa9718a126c",
        "remoteUrl": "https://github.com/sgarner/my-graph/commit/f023dc73242f4783d686732cdac666824bdd81b3"
      }
    }
  }
}

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.