teamwalnut / graphql-ppx

GraphQL language primitives for ReScript/ReasonML written in ReasonML
https://graphql-ppx.com
MIT License
257 stars 53 forks source link

Settings from bsconfig don't seem to be read #273

Closed dfalling closed 2 years ago

dfalling commented 2 years ago

I have the ppx configured in my bsconfig like this:

  "ppx-flags": ["@reasonml-community/graphql-ppx/ppx"],
  "graphql": {
    "apolloMode": true,
    "extendMutation": "ApolloClient.GraphQL_PPX.ExtendMutation",
    "extendQuery": "ApolloClient.GraphQL_PPX.ExtendQuery",
    "extendSubscription": "ApolloClient.GraphQL_PPX.ExtendSubscription",
    "templateTagReturnType": "ApolloClient.GraphQL_PPX.templateTagReturnType",
    "templateTagImport": "gql",
    "templateTagLocation": "@apollo/client",
    "templateTagIsFunction": true
  },

I'd like to use my query like this:

  query TripsQuery {
     trips {
       ...ListTrip
     }
   }

But the compiler warns:

This has type:
    ApolloClient.GraphQL_PPX.templateTagReturnType (defined as
      ApolloClient__Graphql_Language.documentNode)
  Somewhere wanted: string

This problem is fixed if I duplicate the config:

  query TripsQuery (
    templateTagImport: "gql",
    templateTagLocation: "@apollo/client",
    templateTagIsFunction: true,
    templateTagReturnType: "ApolloClient.GraphQL_PPX.templateTagReturnType",
    extend: "ApolloClient.GraphQL_PPX.ExtendQuery"
  ){
     trips {
       ...ListTrip
     }
   }

Is there something I'm missing to make this work? It's pretty bloated to define this config every time I have a fragment, query, or mutation.

Thanks!