use of com.graphql_java_generator.plugin.language.impl.RelationImpl in project graphql-maven-plugin-project by graphql-java-generator.
the class GenerateCodeDocumentParser method initRelations.
/**
* Reads all the GraphQl objects, interfaces, union... that have been read from the GraphQL schema, and list all the
* relations between Server objects (that is: all objects out of the Query/Mutation/Subscription types and the input
* types). The found relations are stored, to be reused during the code generation.<BR/>
* These relations are important for the server mode of the plugin, to generate the proper JPA annotations.
*/
void initRelations() {
for (ObjectType type : getObjectTypes()) {
// We initiate the relations only for regular objects (not query/mutation/subscription)
if (type.getRequestType() == null) {
if (!type.isInputType()) {
for (Field field : type.getFields()) {
if (field.getType() instanceof ObjectType) {
RelationType relType = field.getFieldTypeAST().getListDepth() > 0 ? RelationType.OneToMany : RelationType.ManyToOne;
RelationImpl relation = new RelationImpl(type, field, relType);
//
((FieldImpl) field).setRelation(relation);
relations.add(relation);
}
// if (instanceof ObjectType)
}
// if (!type.isInputType())
}
// for (field)
}
// if (type.getRequestType()== null)
}
// for (type)
}
Aggregations