Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Problems making updates to the schema #43

Closed
axelhzf opened this issue Feb 17, 2019 · 4 comments
Closed

Problems making updates to the schema #43

axelhzf opened this issue Feb 17, 2019 · 4 comments
Labels
question Further information is requested scope/workflow

Comments

@axelhzf
Copy link

axelhzf commented Feb 17, 2019

I have a simple schema like this

const Query = queryType({
  definition(t) {
    t.field("user", {
      type: User,
      nullable: false,
      resolve() {
        return null;
      }
    });
  }
});

And this give the following error because of the nullable

$ ts-node-dev src/index.ts
Using ts-node version 8.0.2, typescript version 3.3.3
[ERROR] 12:02:47 ⨯ Unable to compile TypeScript:
src/index.ts(26,7): error TS2322: Type '() => null' is not assignable to type 'FieldResolver<"Query", "user">'.
  Type 'null' is not assignable to type 'MaybePromise<{ id: MaybePromise<string>; name: MaybePromise<string>; }>'.

The problem is that when I update to nullable: true I still get the same error.
It looks like it is getting the old generated types because it cannot run the server to generate the new types.

@tgriesser
Copy link
Member

If you run with --transpileOnly option it will start the server even with type errors which will then allow it to generate the correct types.

Probably need to add this to the docs/faq since this has come up a few times.

@tgriesser tgriesser added the question Further information is requested label Feb 17, 2019
@axelhzf
Copy link
Author

axelhzf commented Feb 18, 2019

The downside about --transpileOnly transpile only is that it won't detect any errors.

Maybe I could setup an initial step to generate the schema using --transpileOnly and then run the application with error detection enabled.

@tgriesser
Copy link
Member

Generally my workflow when developing is to have two processes running via gulp or similar, one starting/reloading the server with transpile only, one checking for errors.

Then in CI I’ll only have the tsc run so it catches any errors.

@axelhzf
Copy link
Author

axelhzf commented Feb 18, 2019

Ok, that makes sense. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested scope/workflow
Projects
None yet
Development

No branches or pull requests

3 participants