GithubHelp home page GithubHelp logo

ambro17 / graphql-schema-diff Goto Github PK

View Code? Open in Web Editor NEW
45.0 45.0 4.0 1.87 MB

๐Ÿ”Ž Compare GraphQL Schemas and detect Breaking Changes

License: GNU General Public License v3.0

Python 99.34% Makefile 0.57% Dockerfile 0.09%

graphql-schema-diff's Introduction

Ambro17

๐Ÿ‘จโ€๐Ÿ’ป I'm Nahuel Ambrosini, a Python developer which loves to automate the boring stuff.

โšก Currently, my interests are mostly GraphQL APIs Design and automation integrations to pave the way of DevOps

๐Ÿ“š Collaborator of Python Spanish Translation

๐Ÿ’ฌ You can reach me on Telegram at @BoedoCrow if you want to know more about me or some of my projects

๐Ÿ’ผ Working remotely at @shiphero

graphql-schema-diff's People

Contributors

ambro17 avatar checho3388 avatar gonzaloamadio avatar romeroyonatan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

graphql-schema-diff's Issues

Add documentation for Change interface

Document Change attributes and what they mean. It would be nice to document them on the code and be the kickstart for a more complete documentation with sphinx or similar.

Support an allowlist of valid changes

For ci purposes it would be nice to break only if a given change is not on the allowlist.
That document would serve as an api evolution log and should include a checksum of the change and additional details about the date of the change and maybe a reason

CLI only accepts file path and not stdout

Hello @Ambro17

Thank you so much for this tool, it has been very useful.

But something that has been a bit frustrating is trying to run this CLI against a file in the history of git or against a file is piped unix style.

So let's say i have a schema file schema.graphqls and i made a change to this file and commited it to git. It's the same file, so now i have no way of running schemadiff against this file using something like git show HEAD:schema.graphqls

The schemadiff should be able to handle the file outputted from pipes and it's useful to sometimes not have the file in the filesystem but directly piped from another cli.

Right now there is a way to do it using mktemp:

#!/bin/bash

if [ -z "$1" ]; then
    # $1 is not set or is empty
    echo "Error: Missing file path argument."
    echo "Usage: schema_change.sh <schema.graphqls_filepath>"
    exit 1
fi

# Create a temporary file
temp_file=$(mktemp)

# Retrieve the contents of the file from the commit and redirect the output to the temporary file
git show HEAD:$1 > $temp_file

# Pass the name of the temporary file as an argument to schemadiff
schemadiff -o $temp_file -n $1

# remove the temp file
rm $temp_file

ImportError: cannot import name 'TypeFieldResolvers' from 'graphql.type.introspection'

This lib is not working with graphql-core==3.2.0

Traceback (most recent call last):
  File "tests/scripts/validate_schema_is_up_to_date.py", line 3, in <module>
    from schemadiff import diff
  File "/src/virtualenv/lib/python3.7/site-packages/schemadiff/__init__.py", line 6, in <module>
    from schemadiff.diff.schema import Schema
  File "/src/virtualenv/lib/python3.7/site-packages/schemadiff/diff/schema.py", line 10, in <module>
    from graphql.type.introspection import TypeFieldResolvers
ImportError: cannot import name 'TypeFieldResolvers' from 'graphql.type.introspection' (/src/virtualenv/lib/python3.7/site-packages/graphql/type/introspection.py)

Add support for remote schemas

Besides specifying the schema as a string or from a file, it would be nice to support schemas over http as graphql-inspector does.
diff function should still receive a GraphQLSchema object, so a previou steo should handle reading schemas from urls.
https://github.com/ardatan/graphql-toolkit has an interesting loadSchema function that accepts multiple descriptions of a schema

ValidationRules should maintain state between validation and message generation

Problematic Code:
https://github.com/Ambro17/graphql-schema-diff/blob/master/schemadiff/validation.py#L34-L35

As the object is instantiated two times, any atributes set on the validation step will not be available while building the message.

This causes code repetition between validation and message generation when they need to provide extra details about why that change was restricted. For example: The common prefixes shared between two arguments

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.