-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
22 changed files
with
1,984 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...java/io/evitadb/externalApi/graphql/api/catalog/dataApi/model/GlobalEntityDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* | ||
* _ _ ____ ____ | ||
* _____ _(_) |_ __ _| _ \| __ ) | ||
* / _ \ \ / / | __/ _` | | | | _ \ | ||
* | __/\ V /| | || (_| | |_| | |_) | | ||
* \___| \_/ |_|\__\__,_|____/|____/ | ||
* | ||
* Copyright (c) 2023 | ||
* | ||
* Licensed under the Business Source License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/FgForrest/evitaDB/blob/main/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.evitadb.externalApi.graphql.api.catalog.dataApi.model; | ||
|
||
import io.evitadb.externalApi.api.model.ObjectDescriptor; | ||
import io.evitadb.externalApi.api.model.PropertyDescriptor; | ||
|
||
import static io.evitadb.externalApi.api.model.ObjectPropertyDataTypeDescriptor.nonNullRef; | ||
|
||
/** | ||
* Represents global entity with only fields that are present in all entities across all collection.s | ||
* | ||
* @author Lukáš Hornych, FG Forrest a.s. (c) 2023 | ||
*/ | ||
public interface GlobalEntityDescriptor extends GraphQLEntityDescriptor { | ||
|
||
PropertyDescriptor TARGET_ENTITY = PropertyDescriptor.builder() | ||
.name("targetEntity") | ||
.description(""" | ||
Contains a reference to actual collection-specific entity represented by this global entity holder. | ||
""") | ||
.type(nonNullRef(THIS_CLASSIFIER)) | ||
.build(); | ||
|
||
ObjectDescriptor THIS = ObjectDescriptor.extend(THIS_CLASSIFIER) | ||
.name("GlobalEntity") | ||
.description(""" | ||
Catalog-wise entity with only common data across all entity collections. | ||
""") | ||
.staticField(TARGET_ENTITY) | ||
.build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...b/externalApi/graphql/api/catalog/dataApi/resolver/dataFetcher/EntityDtoTypeResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* | ||
* _ _ ____ ____ | ||
* _____ _(_) |_ __ _| _ \| __ ) | ||
* / _ \ \ / / | __/ _` | | | | _ \ | ||
* | __/\ V /| | || (_| | |_| | |_) | | ||
* \___| \_/ |_|\__\__,_|____/|____/ | ||
* | ||
* Copyright (c) 2023 | ||
* | ||
* Licensed under the Business Source License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/FgForrest/evitaDB/blob/main/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.evitadb.externalApi.graphql.api.catalog.dataApi.resolver.dataFetcher; | ||
|
||
import graphql.TypeResolutionEnvironment; | ||
import graphql.schema.GraphQLObjectType; | ||
import graphql.schema.TypeResolver; | ||
import io.evitadb.api.requestResponse.data.EntityClassifier; | ||
import io.evitadb.externalApi.graphql.exception.GraphQLQueryResolvingInternalError; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Resolve specific entity DTO for entity interface based on fetched original entity object. | ||
* | ||
* @author Lukáš Hornych, FG Forrest a.s. (c) 2022 | ||
*/ | ||
@RequiredArgsConstructor | ||
public class EntityDtoTypeResolver implements TypeResolver { | ||
|
||
private final Map<String, GraphQLObjectType> entityTypeToEntityDtoMapping; | ||
|
||
@Nonnull | ||
@Override | ||
public GraphQLObjectType getType(@Nonnull TypeResolutionEnvironment env) { | ||
final EntityClassifier entity = env.getObject(); | ||
return Optional.ofNullable(entityTypeToEntityDtoMapping.get(entity.getType())) | ||
.orElseThrow(() -> new GraphQLQueryResolvingInternalError("Missing entity dto for entity type `" + entity.getType() + "`.")); | ||
} | ||
} |
Oops, something went wrong.