Repository navigation
Conversation
|
84a5b99 to
ea740ef
Compare
0a95b71 to
3dfdab1
Compare
|
thanks a lot @felipe-gdr. Please have a look at the Graphql JS PR as sanity check: graphql/graphql-js#2084 |
|
Yep, good idea. |
|
Looking at the graphq-js implementation was a good idea. I've simplified the validation code quite a bit. I didn't have to use recursion to find circular dependencies since the list of implemented interfaces is flattened at each interface type. 👍 |
311ef32 to
4015f0d
Compare
| assertErrorMessage(error, "The interface extension type 'BaseInterface' [@n:n] has tried to redefine field 'fieldB' arguments defined via interface 'InterfaceType' [@n:n] from 'arg3:Int' to 'arg3:String") | ||
| } | ||
|
|
||
| def assertErrorMessage(SchemaProblem error, expectedMessage) { |
There was a problem hiding this comment.
Nice one! We should do this in other tests.
Can you please rewrite all our tests to this pattern please! ;)
| # | ||
| extend type BaseType implements Interface1 { | ||
| extraField1 : String | ||
| } |
There was a problem hiding this comment.
Why does this need to be removed? Is it no longer valid or just not longer relevant and tested in the other places
There was a problem hiding this comment.
This is actually invalid now.
I've added a new validation rule which prevents extensions from implementing an interface which has already been implemented from a base type, or other extensions for the same type.
This will make the graphql-java validation more aligned with graphql-js
| field21: String | ||
| } | ||
|
|
||
| extend type Type1 implements Interface2 { |
There was a problem hiding this comment.
My comment below is covered by this test
|
Wow this is impressive code - neat and conscice but readable |
andimarek
left a comment
There was a problem hiding this comment.
great work. Did a first review. See my comments.
We also should have a "integration test" for the introspection result, what do you think?
| interfaceTypeDefinition.description(toDescription(input)); | ||
| if (input.containsKey("interfaces") && input.get("interfaces") != null) { | ||
| interfaceTypeDefinition.implementz( | ||
| ((List<Map<String, Object>>) input.get("interfaces")).stream() |
There was a problem hiding this comment.
please use our map static function instead of streams directly
| * @param <T> | ||
| */ | ||
| @PublicApi | ||
| public interface ImplementingTypeDefinition<T extends ImplementingTypeDefinition> extends TypeDefinition<T> { |
There was a problem hiding this comment.
why the recursive type definition here?
There was a problem hiding this comment.
Yep, not needed. <T extends TypeDefinition> should be enough.
| @PublicApi | ||
| public interface ImplementingTypeDefinition<T extends ImplementingTypeDefinition> extends TypeDefinition<T> { | ||
|
|
||
| List<Type> getImplements(); |
There was a problem hiding this comment.
not great name, but not in scope to change it here.
| private List<Type> getImplementz(GraphqlParser.ImplementsInterfacesContext implementsInterfacesContext) { | ||
| List<Type> implementz = new ArrayList<>(); | ||
| while (implementsInterfacesContext != null) { | ||
| List<TypeName> typeNames = implementsInterfacesContext.typeName().stream().map(this::createTypeName).collect(toList()); |
There was a problem hiding this comment.
please use our map util function.
| private void checkForMissingTypes(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry) { | ||
| // type extensions | ||
| List<ObjectTypeExtensionDefinition> typeExtensions = typeRegistry.objectTypeExtensions().values().stream().flatMap(Collection::stream).collect(Collectors.toList()); | ||
| List<ObjectTypeExtensionDefinition> typeExtensions = typeRegistry.objectTypeExtensions().values().stream().flatMap(Collection::stream).collect(toList()); |
There was a problem hiding this comment.
FpKit#flatList applies to List<List<>> and we have a Collection<List<>> here.
Should we create a more generic flatten method in FpKit?
| */ | ||
| public List<ObjectTypeDefinition> getImplementationsOf(InterfaceTypeDefinition targetInterface) { | ||
| List<ObjectTypeDefinition> objectTypeDefinitions = getTypes(ObjectTypeDefinition.class); | ||
| public List<ImplementingTypeDefinition> getImplementationsOf(InterfaceTypeDefinition targetInterface) { |
There was a problem hiding this comment.
this is a breaking change. Should we consider adding another one and keeping this one for use object implementations?
There was a problem hiding this comment.
Yep, just noticed that this is public API. I'll create a new method.
- use FpKit - fix Generic definition in ImplementingTypeDefinition - don't break public API in TypeDefinitionRegistry
1339a86 to
04cfbe7
Compare
fix introspection interfaces field
and test SchemaPrinter
|
We need to add a verification for programmatically created GraphQLTypes that they declare all interfaces transitively. Also we need to look at AstPrinter if it prints correctly and add a test. |
Allows interfaces to implement other interfaces, as described in the draft spec.
fixes: #1764