Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

There is some bug preventing from generating bindings for app itself #65

Open
pie6k opened this issue Jan 6, 2018 · 1 comment
Open

Comments

@pie6k
Copy link

pie6k commented Jan 6, 2018

Steps to reproduce

Modify .graphqlconfig.yml to:

projects:
  app:
    schemaPath: "src/schema.graphql"
    includes: ["queries/{booking,queries}.graphql"]
    extensions:
      prepare-bundle: src/generated/app.graphql
      endpoints:
        default: "http://localhost:5000"
        prepare-bundle: src/generated/app.graphql
      prepare-binding:
        output: src/generated/app.ts
        generator: graphcool-ts
  database:
    schemaPath: "src/generated/database.graphql"
    includes: ["database/seed.graphql"]
    extensions:
      graphcool: graphcool.yml
      prepare-binding:
        output: src/generated/graphcool.ts
        generator: graphcool-ts

Run yarn prepare

Expected: complie bindings for app schema

Actual: Error:
TypeError: Cannot read property 'type' of undefined when I've found out happens in node_modules/graphql-static-binding/dist/generators/graphcool-ts.js:48:89:

var whereType = field.args.find(function (a) { return a.name === 'where'; }).type.name; 
// field.args is undefined!!!

I was trying to dig a bit deeper but I then I had too little knowledge about project itself to realize what is really going on.

My workaround was changing generator from graphcool-ts to binding-ts and it worked but I have no idea why.

Also, it took me a while to realize I needed to add prepare-bundle: src/generated/app.graphql to app.extensions to have all imports working. My intuition was to add bundle: true to prepare-binding options but it was not working.

@kbrandwijk
Copy link
Contributor

I think the culprit is the extra prepare-bundle on the endpoint.
The config options are explained here: https://github.com/supergraphql/graphql-cli-prepare#graphql-config-extensions.
Also, the app schema is not a Graphcool schema. There is some stuff in the graphcool-ts generator that is Graphcool specific, so your decision to use binding-ts (the generic version) instead, was correct.

There will be improved documentation around this topic.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants