mhallin / graphql_ppx

GraphQL PPX rewriter for Bucklescript/ReasonML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated AST is not compat with graphql-tag

thangngoc89 opened this issue · comments

This is a list of differences between the AST generated by this ppx and graphql-tag

1. Simple query

Query:

module PatientsQuery = [%graphql
  {|
  query allPatients {
    patients: patientsConnection(first: 20) {
      edges {
        node {
          id
          patientId: externalId
          phone
          address
          name
          gender
          ageInYears
        }
      }
    }
  }
  |}
];

ppx : https://gist.github.com/thangngoc89/707524bb00dcc573f69f60bb0a776ac9#file-1-ppx-json
tag: https://gist.github.com/thangngoc89/707524bb00dcc573f69f60bb0a776ac9#file-1-tag-json

Diff (left: ppx, right: tag)
image

After I edit the generated JS, apollo client could use this without issue

2. Query with arguments

This is the same query with above but with arguments and input

query allPatients($first: Int!) {
    patients: patientsConnection(first: $first) {
      edges {
        node {
          id
          patientId: externalId
          phone
          address
          name
          gender
          ageInYears
        }
      }
    }
  }

ppx : https://gist.github.com/thangngoc89/707524bb00dcc573f69f60bb0a776ac9#file-2-ppx-json
tag: https://gist.github.com/thangngoc89/707524bb00dcc573f69f60bb0a776ac9#file-2-tag-json

Diff (left: ppx, right: tag)
image

In this case, even if I edited this generated JS, apollo-client stills send an malformed query like this (notice the [Object object] )

image

Thank you for finding this. I just published 0.2.1 which should fix this issue. Please let me know if there still are compatibility issues.