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

Improve constraint schema generator context switching #678

Open
lukashornych opened this issue Oct 1, 2024 · 0 comments
Open

Improve constraint schema generator context switching #678

lukashornych opened this issue Oct 1, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@lukashornych
Copy link
Collaborator

When building child parameter for specific nonabstract type io/evitadb/externalApi/graphql/api/catalog/dataApi/builder/constraint/GraphQLConstraintSchemaBuilder.java:228 (io.evitadb.externalApi.graphql.api.catalog.dataApi.builder.constraint.GraphQLConstraintSchemaBuilder#buildChildConstraintValue), it should not resolve child domain from property type as this neglects the custom domain from the parent child parameter, which is not neglected when a full container is build. This way, we cannot define custom domain for the inside of the child constraint. Instead, we should probably go deeper and somehow resolve domain for the parameters of the concrete constraint of the parent child parameter.

Specific example is the Segment constraint where we want to use OrderBy container with entity domain for its children, but in current implementation, the entity domain is converted to the generic domain of OrderBy constraint and the entity domain and its purpose to generate children for entity within OrderBy is lost:

public Segment(
	@Nullable @AdditionalChild(domain = ConstraintDomain.ENTITY) EntityHaving entityHaving,
	@Nonnull @Child(domain = ConstraintDomain.ENTITY) OrderBy orderBy,
	@Nullable @Child(domain = ConstraintDomain.SEGMENT) SegmentLimit limit
) { }

The desired logic works for additional children, because there is no domain-from-property-type convertion, so maybe we should utilize something similar even for direct children.

Workaround for now is to not use specific class for generic containers for direct children, instead define its children directly:

public Segment(
	@Nullable @AdditionalChild(domain = ConstraintDomain.ENTITY) EntityHaving entityHaving,
	@Nonnull @Child(domain = ConstraintDomain.ENTITY) OrderConstraint[] orderBy,
	@Nullable @Child(domain = ConstraintDomain.SEGMENT) SegmentLimit limit
) { }

Also, we should filter by domain even in these methods io.evitadb.api.query.descriptor.ConstraintDescriptorProvider#getConstraint* not only by class. However, this is dependent on the first issue.

@lukashornych lukashornych self-assigned this Oct 1, 2024
@lukashornych lukashornych added the bug Something isn't working label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant