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

Typescript type safety #141

Merged
merged 2 commits into from
Feb 6, 2018

Conversation

felixfbecker
Copy link
Contributor

Closes #138

I used the broadest possible version range for @types/graphql that exports DocumentNode to get the biggest chance of deduping.

Also changed the string tag signature to not use any, like String.raw.

@apollo-cla
Copy link

@felixfbecker: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@@ -20,7 +20,9 @@
"url": "https://github.com/apollostack/graphql-tag/issues"
},
"homepage": "https://github.com/apollostack/graphql-tag#readme",
"dependencies": {},
"dependencies": {
"@types/graphql": ">=0.8.6 <=0.11.7"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.12.x should also export DocumentNode, how about >=0.8.6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time I opened this PR 0.12 didn't exist, will update.
I don't understand the second question? 0.8.6 was the first version to export it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that by just specifying the dependency as "@types/graphql": ">=0.8.6", and omitting the <=x.x.x the right hand side won't continue to need to be bumped each time a release is cut.

Copy link
Contributor Author

@felixfbecker felixfbecker Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know the next version does not contain a breaking change? It doesn't have to be bumped every time a release is cut, it's an interface so it will work fine if you use a different version in your project that is compatible

@4F2E4A2E
Copy link

4F2E4A2E commented Feb 6, 2018

@felixfbecker did you sign the agreement?
Will this PR request be accepted any time soon? Is there help needed?
We hope to be able to create queries directly in typescript by this.

@felixfbecker
Copy link
Contributor Author

Yes I did. I cant tell you if this will get merged anytime soon. Seems like nobody is maintaining this project

@jnwng jnwng merged commit 204cd50 into apollographql:master Feb 6, 2018
@jnwng
Copy link
Contributor

jnwng commented Feb 6, 2018

thank you!

@4F2E4A2E
Copy link

4F2E4A2E commented Feb 6, 2018

@felixfbecker can you provide an example?

@felixfbecker
Copy link
Contributor Author

Thanks @jnwng!
@4F2E4A2E Sorry, what do you want an example for?

@felixfbecker felixfbecker deleted the typescript-type-safety branch February 6, 2018 17:49
@jnwng
Copy link
Contributor

jnwng commented Feb 6, 2018

live in [email protected]

@paulcpk
Copy link

paulcpk commented Feb 6, 2018

Interpreting the question by @4F2E4A2E:

@felixfbecker can you provide an example?

@felixfbecker Could you provide an example of how gql is now able to generate type safe graphQL queries, as proposed in #138?

Thanks a lot! 😃

@4F2E4A2E
Copy link

4F2E4A2E commented Feb 6, 2018

@felixfbecker just got a closer look at your pr => it was about the return value and not about type safe queries. Sorry for that. Anyway, it seams not to be possible right, but i ask anyway, do someone know a way to define graphql queries type safe with typescript?

@felixfbecker
Copy link
Contributor Author

@4F2E4A2E there is a TypeScript language service plugin that gives you autocompletion for fields and you can generate typings for the return types of queries. Not aware of other solutions.

@4F2E4A2E
Copy link

4F2E4A2E commented Feb 6, 2018

@felixfbecker thanks, do you mean the visual code plugin? Have checked that out already, it's only for vs. I am looking for a ts solution which can be validate via type safty.

@felixfbecker
Copy link
Contributor Author

No, I am talking about https://github.com/Quramy/ts-graphql-plugin. This is getting a bit off topic here, I would suggest you move this over to StackOverflow or Gitter if you need more help

@4F2E4A2E
Copy link

4F2E4A2E commented Feb 6, 2018

StackOverflow is great thanks, but that link is what i meant by visual code => no that's not it, I am looking for a type safe way to write graphql queries via typescript. Thanks anyway 👍

@felixfbecker
Copy link
Contributor Author

That link is not a Visual Studio Code plugin. It's a TypeScript language service plugin. You define it in tsconfig.json. It will work with any editor that uses the TypeScript language service, e.g. Atom or Sublime.

jnwng added a commit to jnwng/graphql-tag that referenced this pull request Feb 7, 2018
jnwng added a commit that referenced this pull request Feb 7, 2018
* 2.7.0

* 2.7.1

* 2.7.2

* Revert "Typescript type safety (#141)"

This reverts commit 204cd50.

* 2.7.3
@jnwng jnwng mentioned this pull request Jul 20, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants