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

RFC: Client Controlled Nullability Operators Implementation #3281

Closed
wants to merge 65 commits into from

Conversation

twof
Copy link
Contributor

@twof twof commented Sep 29, 2021

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 29, 2021

CLA Signed

The committers are authorized under a signed CLA.

package.json Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
@twof
Copy link
Contributor Author

twof commented Sep 29, 2021

CLA Signed

The committers are authorized under a signed CLA.

@saihaj
Copy link
Member

saihaj commented Sep 30, 2021

@twof try rebasing and overwriting author on commits https://stackoverflow.com/a/54363151/11321732

@twof twof force-pushed the operatorImplementation branch 2 times, most recently from f44f30d to 05f95f7 Compare October 5, 2021 21:10
@twof twof marked this pull request as ready for review October 5, 2021 21:13
@twof
Copy link
Contributor Author

twof commented Oct 5, 2021

@saihaj Thanks! That worked.

@IvanGoncharov IvanGoncharov added the spec RFC Implementation of a proposed change to the GraphQL specification label Oct 8, 2021
@IvanGoncharov
Copy link
Member

@twof I enabled CI, and some tests are failing.

@IvanGoncharov IvanGoncharov added the PR: feature 🚀 requires increase of "minor" version number label Oct 8, 2021
@twof
Copy link
Contributor Author

twof commented Oct 12, 2021

@IvanGoncharov Thanks! I'll go through these issues.

src/execution/execute.ts Outdated Show resolved Hide resolved
@twof
Copy link
Contributor Author

twof commented Oct 12, 2021

@IvanGoncharov Mind kicking this off again? I think I've resolved the issues. I also ran the test coverage checker locally, and it looks like we ought to be good to go I think.

@twof
Copy link
Contributor Author

twof commented Oct 12, 2021

Thanks! I'll fix that spelling

@@ -12,6 +12,7 @@ import { getNamedType, isCompositeType } from '../../type/definition';

import { buildSchema } from '../buildASTSchema';
import { TypeInfo, visitWithTypeInfo } from '../TypeInfo';
import { ComplexRequiredStatus } from '../../language/ast';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might need a test in this file somewhere

Comment on lines 596 to 615
// Errors will have already been handled by RequiredStatusOnFieldMatchesDefinitionRule
// so there's no need to do anything here in the event that modifiedOutputType throws
// an error.
try {
var modifiedType1 = modifiedOutputType(type1, node1.required);
var modifiedType2 = modifiedOutputType(type2, node2.required);

if (doTypesConflict(modifiedType1, modifiedType2)) {
return [
[
responseName,
`they return conflicting types "${inspect(
modifiedType1,
)}" and "${inspect(modifiedType2)}"`,
],
[node1],
[node2],
];
}
} catch {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it okay not handling errors here if I expect the errors these functions throw to be handled in a different rule? Is there any reason to think one rule will be run and the other won't?

* A GraphQL document is only valid if all fields selected are defined by the
* parent type, or are an allowed meta field such as __typename.
*
* See https://spec.graphql.org/draft/#sec-Field-Selections
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update this link once I've added this rule to the spec

@twof
Copy link
Contributor Author

twof commented Nov 30, 2021

@IvanGoncharov I'll take a look at those failing jobs in the morning, but npm test is passing on my machine. In the meantime if you'd like to look at the changes I've made and let me know what you think, the architecture is ready for review again.

I'll go over everything and do some cleanup in the morning, so don't worry too much about the details for now. Also let me know if there are any portions you'd like me to write up explanations for.

Summary of changes:

  • ComplexRequiredStatus has been broken up into three Node interfaces.
  • Printing and parsing is now much simpler. You were totally right about that.
  • modifiedOutputType now also uses a visitor.
  • Based on feedback on the spec PR, I'm requiring that nullability modifiers match the list depth for the field they're modifying. If I get pushback on that, we can loosen that restriction, or we can loosen it in a later release without making any breaking changes.

Todo:

  • People haven't landed on behavior for the question mark syntax yet, but that's liable to cause significant changes to this implementation.

@twof
Copy link
Contributor Author

twof commented Dec 7, 2021

@IvanGoncharov Hey Ivan. During the meeting last Thursday you mentioned that you'd be open to releasing this feature behind an experimental flag while it's still in review, and you had some other features that did something similar in the past. Are you able to point me towards an example of a feature that used an experimental flag? I can implement something similar as part of this PR if you're still interested in doing that.

@saihaj
Copy link
Member

saihaj commented Dec 7, 2021

Hey @twof we currently publish defer and stream as experimental flag you can read more here: https://github.com/graphql/graphql-js#experimental-features. I think for this to happen we first need to get your this branch to the repo. So @IvanGoncharov can help you give rights and set up a branch here which you can push to. Then each time there are changes we just publish a new experimental tag example: https://github.com/graphql/graphql-js/releases/tag/v16.0.0-experimental-stream-defer.5.

But I think this approach really isn't working well and @IvanGoncharov wanted to merge everything to main so we can have unstable main and have canary releases. But as per JS-WG it was suppose to happen last Monday or Wednesday (as per a comment I saw) but no updates on that end. But hopefully we can get something this week and have this merged soon cause I want to play around with this feature :) cause I don't want to build myself or start publishing on my fork.

@saihaj
Copy link
Member

saihaj commented Dec 7, 2021

but npm test is passing on my machine

I assume you are on node v16 cause v16 tests are the only ones passing.

src/utilities/applyRequiredStatus.ts Outdated Show resolved Hide resolved
@twof
Copy link
Contributor Author

twof commented Dec 7, 2021

@saihaj Great! Let me know if there's anything I can do to help with the experimental flag setup, or if yall have anything else I can fix up about the PR. It looks like most checks are passing.

@twof twof requested a review from saihaj December 7, 2021 07:00
@IvanGoncharov
Copy link
Member

@twof I suggest moving in steps.
As the first step let's merge support for ! and ? in AST (parse, print, AST types, visit, etc.).
Please split out a smaller PR with just AST changes similar to this one #1141 (note it's more than 4 years old, so code changed a bit since then).
I think one experimental flag for both ! and ? would be enough.
Also please make a short summary of the discussion around ! and ? syntax (only syntax) and open questions if any and add them in the commit message (or PR message).

That way we will merge noncontroversial stuff first and focus on stuff that needs disscussion.
Also, it will unblock your work with apollo-ios and graphql-codegen.

@twof
Copy link
Contributor Author

twof commented Dec 8, 2021

@IvanGoncharov Here's the PR with the stuff you asked for: #3418

@twof
Copy link
Contributor Author

twof commented Dec 16, 2021

Hey @michaelstaib! Thanks for the review. I'm in the process of breaking up this PR into smaller changesets. I've addressed your feedback for the ? and ! portions of the proposal in #3418 and your feedback related to the list syntax in twof#2.

@IvanGoncharov @saihaj In order to reduce confusion, would it be helpful to close this PR and designate #3418 as the canonical implementation branch for this RFC?

@twof twof closed this Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature 🚀 requires increase of "minor" version number spec RFC Implementation of a proposed change to the GraphQL specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants