Skip to content

Allow schema diff to use SDL document to enforce directives #3344

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

Merged
merged 4 commits into from
Oct 11, 2023
Merged

Allow schema diff to use SDL document to enforce directives #3344

merged 4 commits into from
Oct 11, 2023

Conversation

ndejaco2
Copy link
Contributor

@ndejaco2 ndejaco2 commented Oct 4, 2023

This PR is made to fix a bug (#3343) with SchemaDiff where the enforceDirectives option is not working properly.

  • In this PR, I deprecate the DiffSet class and introduce the new SchemaDiffSet interface in place of it.
  • There are two implementations of SchemaDiffSet provided: IntrospectionSchemaDiffSet and SDLSchemaDiffSet.
  • Since introspection query does not return which elements directives are applied on, it does not properly enforce directives.
  • The SDL schema diff set should always be used when attempting to enforce directives in a schema diff.
  • I updated the unit tests to use both methods and validate that the response is equivalent for all but the directives use case.
  • I am not super familiar with how major versioning is managed in this package, but I left the old implementation available and just marked it as Deprecated so let me know if there is any other way of going about this.

…tion result in order to enforce directives in schema diff
@bbakerman
Copy link
Member

Thanks for this PR... I am looking into it now

public SDLSchemaDiffSet(final String oldSchemaSdl, final String newSchemaSdl) {
this.oldSchemaSdl = oldSchemaSdl;
this.newSchemaSdl = newSchemaSdl;
}
Copy link
Member

Choose a reason for hiding this comment

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

why store these as Strings and then parse them in the getter. At this point you cant know they are valid documents

I think it would be better if it was private SDLSchemaDiffSet(final Document oldSchemaSdl, final Document newSchemaSdl)

Also make this constructor private. We have static constructor methods and the change in signature I mentioned above would be possible with private constructors and a breaking change when the they are public. private constructors on classes should be a starting point

Copy link
Contributor Author

@ndejaco2 ndejaco2 Oct 9, 2023

Choose a reason for hiding this comment

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

Sounds good to me. I do wonder if its worth it to have two classes: SDLSchemaDiffSet and IntrospectionSchemaDiffSet when they both will just be created with documents. I think in this case it would be better to merge it as a single class and just add a flag in the builder that introspection will not properly enforce directives? I went ahead and did it that way, let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine idea

public IntrospectionSchemaDiffSet(Map<String, Object> introspectionOld, Map<String, Object> introspectionNew) {
this.introspectionOld = introspectionOld;
this.introspectionNew = introspectionNew;
}
Copy link
Member

Choose a reason for hiding this comment

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

again as discussed below - store this as a Document not a Map<String, Object> (I know the old code did but we get a chance to be better with new code)

and make this constructor private

@bbakerman bbakerman added this to the 2023 October milestone Oct 11, 2023
@bbakerman bbakerman added this pull request to the merge queue Oct 11, 2023
Merged via the queue into graphql-java:master with commit 41ee58c Oct 11, 2023
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.

2 participants