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

deprecate fragments everywhere #984

Merged
merged 3 commits into from
Dec 3, 2016
Merged

deprecate fragments everywhere #984

merged 3 commits into from
Dec 3, 2016

Conversation

helfer
Copy link
Contributor

@helfer helfer commented Dec 2, 2016

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change
  • Add your name and email to the AUTHORS file (optional)
  • If this was a change that affects the external API, update the docs and post a link to the PR in the discussion

Copy link
Contributor

@stubailo stubailo left a comment

Choose a reason for hiding this comment

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

A few comments!

@@ -249,10 +255,23 @@ export default class ApolloClient {
}) as DeprecatedWatchQueryOptions;
}

if (options.fragments && !haveWarnedWatchQuery && process.env.NODE_ENV !== 'production') {
console.warn(
'"fragments" option is deprecated and will be removed in the upcoming versions, ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say "in 0.6" rather than "upcoming versions"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

// deprecation warning flags
let haveWarnedQuery = false;
let haveWarnedWatchQuery = false;
let haveWarnedMutation = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why separate these? I feel like we could just have one haveWarned variable, since the warning messages are the same anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point. Probably not worth changing though.

@@ -1358,7 +1358,9 @@ it('should not let errors in observer.next reach the store', (done) => {
// hacky solution that allows us to test whether the warning is printed
const oldWarn = console.warn;
console.warn = (str: string) => {
assert.include(str, 'Warning: fragment with name');
if (!str.match(/deprecated/)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I decided to take a shortcut here because it affected lots of tests and wasn't easy to see which ones. I intend to remove the line after deprecating fragments. I wouldn't do it for deprecating things in general, but I think it's okay to do it in this instance because fragments affect many more test cases than future deprecations will affect.

Choose a reason for hiding this comment

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

The warning is showing up whether or not you're using createFragment because react-apollo is using it here https://github.com/apollostack/react-apollo/blob/a23883fd226e0352813b4889cf647964c4c0e0fc/src/parser.ts#L8

It's a little annoying to have a warning suddenly appear in every console when you can't do much about it.

Copy link
Contributor Author

@helfer helfer Dec 5, 2016

Choose a reason for hiding this comment

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

@jasonnathan have you filed an issue on react-apollo? That would be the best way to make sure it gets fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@helfer helfer merged commit 2b0755b into master Dec 3, 2016
@helfer helfer removed the in progress label Dec 3, 2016
@helfer helfer deleted the remove-fragments branch December 3, 2016 12:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants