JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Example-driven architecture #506

Open neopaf opened 2 years ago

neopaf commented 2 years ago

(1B thanks for your efforts!)

For discussion with colleagues I like to provide examples of possible API interactions.

Please consider supporting some way to validate example query results.

So when I write an example, like this one below, and, say, inside msisdn object press IntelliSense autocomplete button I would get relatedPartyRole suggested.

example1-result1.graphql.json file with example result:

{
  "data": {
    "msisdn": {
      "relatedPartyRole": {
        "partyOrderItems": [
          {
            "product": {
              "productOffering": {
                "id": "Test1"
              },
              "customerFacingServices": [
                {
                  "id": "INTERNET",
                  "resourceFacingServices": [
                    {
                      "id": "DNS"
                      ...

example1.graphql example query:

query PartyRoleByMSISDN_WithProductsAndServices($msisdn: String!) {
    msisdn(v: $msisdn){
        relatedPartyRole {
            partyOrderItems {
                product {
                    productOffering {
                        id
                    }
                    customerFacingServices {
                        id
                        resourceFacingServices {
                            id
                        }
                    }
                }
            }
        }
    }
}

Not sure how to optimally link these two files to know which query was used to which example results.

One way -- naming convention (there is a file that starts with same name as our file and has .graphql extension). The other -- some control-comments, but some people don't like comments in JSON. This is minor point.

They key -- is this doable and how much effort it might take.

Since this check is not only against GraphQL schema (which is implemented already) but also against particular query, where we may have not all fields of some type, but a subset.