@Test public void createAnEmptySchemaWhenNoPropertiesAreAdded() { String schema = instanceNoProv.getSchema().toString(); assertThat(schema, isEmptyString()); }
public StringBuilder getSchema() { StringBuilder schema = new StringBuilder(); if (creations.isEmpty() && additions.isEmpty() && deletions.isEmpty() && replacements.isEmpty()) { return schema; } String name = graphQlNameGenerator.createObjectTypeName(rootType, typeUri); if (!creations.isEmpty()) { schema.append("input ").append(name).append("CreateInput").append(" {\n"); schema.append(" creations: ").append(name).append("CreationsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append("input ").append(name).append("EditInput").append(" {\n"); if (!additions.isEmpty()) { schema.append(" additions: ").append(name).append("AdditionsInput\n"); } if (!deletions.isEmpty()) { schema.append(" deletions: ").append(name).append("DeletionsInput\n"); } schema.append(" replacements: ").append(name).append("ReplacementsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!deletions.isEmpty() && hasCustomProvenance) { schema.append("input ").append(name).append("DeleteInput").append(" {\n"); schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); schema.append("}\n\n"); } if (!creations.isEmpty()) { inputFields(schema, name, "CreationsInput", creations); } if (!replacements.isEmpty()) { inputFields(schema, name, "ReplacementsInput", replacements); } if (!additions.isEmpty()) { inputFields(schema, name, "AdditionsInput", additions); } if (!deletions.isEmpty()) { inputFields(schema, name, "DeletionsInput", deletions); } schema.append("type ").append(name).append("Mutations").append(" {\n"); if (!creations.isEmpty()) { schema.append(" create(").append("uri: String! ").append("entity: ").append(name).append("CreateInput!): ") .append(name).append(" @createMutation(dataSet: \"").append(rootType).append("\"") .append(" typeUri: \"").append(typeUri).append("\")").append("\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append(" edit(").append("uri: String! ").append("entity: ").append(name).append("EditInput!): ") .append(name).append(" @editMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } if (!deletions.isEmpty() && !hasCustomProvenance) { schema.append(" delete(").append("uri: String!): RemovedEntity! ") .append("@deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } else if (!deletions.isEmpty()) { schema.append(" delete(").append("uri: String! ").append("entity: ").append(name).append("DeleteInput): ") .append("RemovedEntity! @deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } schema.append(" persistEntity(").append("entityUri: String!): ").append("Message") .append(" @persistEntityMutation(dataSet: \"").append(rootType).append("\")").append("}\n"); return schema; }
DerivedInputTypeSchemaGenerator { public StringBuilder getSchema() { StringBuilder schema = new StringBuilder(); if (creations.isEmpty() && additions.isEmpty() && deletions.isEmpty() && replacements.isEmpty()) { return schema; } String name = graphQlNameGenerator.createObjectTypeName(rootType, typeUri); if (!creations.isEmpty()) { schema.append("input ").append(name).append("CreateInput").append(" {\n"); schema.append(" creations: ").append(name).append("CreationsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append("input ").append(name).append("EditInput").append(" {\n"); if (!additions.isEmpty()) { schema.append(" additions: ").append(name).append("AdditionsInput\n"); } if (!deletions.isEmpty()) { schema.append(" deletions: ").append(name).append("DeletionsInput\n"); } schema.append(" replacements: ").append(name).append("ReplacementsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!deletions.isEmpty() && hasCustomProvenance) { schema.append("input ").append(name).append("DeleteInput").append(" {\n"); schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); schema.append("}\n\n"); } if (!creations.isEmpty()) { inputFields(schema, name, "CreationsInput", creations); } if (!replacements.isEmpty()) { inputFields(schema, name, "ReplacementsInput", replacements); } if (!additions.isEmpty()) { inputFields(schema, name, "AdditionsInput", additions); } if (!deletions.isEmpty()) { inputFields(schema, name, "DeletionsInput", deletions); } schema.append("type ").append(name).append("Mutations").append(" {\n"); if (!creations.isEmpty()) { schema.append(" create(").append("uri: String! ").append("entity: ").append(name).append("CreateInput!): ") .append(name).append(" @createMutation(dataSet: \"").append(rootType).append("\"") .append(" typeUri: \"").append(typeUri).append("\")").append("\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append(" edit(").append("uri: String! ").append("entity: ").append(name).append("EditInput!): ") .append(name).append(" @editMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } if (!deletions.isEmpty() && !hasCustomProvenance) { schema.append(" delete(").append("uri: String!): RemovedEntity! ") .append("@deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } else if (!deletions.isEmpty()) { schema.append(" delete(").append("uri: String! ").append("entity: ").append(name).append("DeleteInput): ") .append("RemovedEntity! @deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } schema.append(" persistEntity(").append("entityUri: String!): ").append("Message") .append(" @persistEntityMutation(dataSet: \"").append(rootType).append("\")").append("}\n"); return schema; } }
DerivedInputTypeSchemaGenerator { public StringBuilder getSchema() { StringBuilder schema = new StringBuilder(); if (creations.isEmpty() && additions.isEmpty() && deletions.isEmpty() && replacements.isEmpty()) { return schema; } String name = graphQlNameGenerator.createObjectTypeName(rootType, typeUri); if (!creations.isEmpty()) { schema.append("input ").append(name).append("CreateInput").append(" {\n"); schema.append(" creations: ").append(name).append("CreationsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append("input ").append(name).append("EditInput").append(" {\n"); if (!additions.isEmpty()) { schema.append(" additions: ").append(name).append("AdditionsInput\n"); } if (!deletions.isEmpty()) { schema.append(" deletions: ").append(name).append("DeletionsInput\n"); } schema.append(" replacements: ").append(name).append("ReplacementsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!deletions.isEmpty() && hasCustomProvenance) { schema.append("input ").append(name).append("DeleteInput").append(" {\n"); schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); schema.append("}\n\n"); } if (!creations.isEmpty()) { inputFields(schema, name, "CreationsInput", creations); } if (!replacements.isEmpty()) { inputFields(schema, name, "ReplacementsInput", replacements); } if (!additions.isEmpty()) { inputFields(schema, name, "AdditionsInput", additions); } if (!deletions.isEmpty()) { inputFields(schema, name, "DeletionsInput", deletions); } schema.append("type ").append(name).append("Mutations").append(" {\n"); if (!creations.isEmpty()) { schema.append(" create(").append("uri: String! ").append("entity: ").append(name).append("CreateInput!): ") .append(name).append(" @createMutation(dataSet: \"").append(rootType).append("\"") .append(" typeUri: \"").append(typeUri).append("\")").append("\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append(" edit(").append("uri: String! ").append("entity: ").append(name).append("EditInput!): ") .append(name).append(" @editMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } if (!deletions.isEmpty() && !hasCustomProvenance) { schema.append(" delete(").append("uri: String!): RemovedEntity! ") .append("@deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } else if (!deletions.isEmpty()) { schema.append(" delete(").append("uri: String! ").append("entity: ").append(name).append("DeleteInput): ") .append("RemovedEntity! @deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } schema.append(" persistEntity(").append("entityUri: String!): ").append("Message") .append(" @persistEntityMutation(dataSet: \"").append(rootType).append("\")").append("}\n"); return schema; } DerivedInputTypeSchemaGenerator(String typeUri, String rootType, GraphQlNameGenerator graphQlNameGenerator,
                                         DerivedSchemaContainer derivedSchemaContainer,
                                         ReadOnlyChecker readOnlyChecker, CustomProvenance customProvenance); }
DerivedInputTypeSchemaGenerator { public StringBuilder getSchema() { StringBuilder schema = new StringBuilder(); if (creations.isEmpty() && additions.isEmpty() && deletions.isEmpty() && replacements.isEmpty()) { return schema; } String name = graphQlNameGenerator.createObjectTypeName(rootType, typeUri); if (!creations.isEmpty()) { schema.append("input ").append(name).append("CreateInput").append(" {\n"); schema.append(" creations: ").append(name).append("CreationsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append("input ").append(name).append("EditInput").append(" {\n"); if (!additions.isEmpty()) { schema.append(" additions: ").append(name).append("AdditionsInput\n"); } if (!deletions.isEmpty()) { schema.append(" deletions: ").append(name).append("DeletionsInput\n"); } schema.append(" replacements: ").append(name).append("ReplacementsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!deletions.isEmpty() && hasCustomProvenance) { schema.append("input ").append(name).append("DeleteInput").append(" {\n"); schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); schema.append("}\n\n"); } if (!creations.isEmpty()) { inputFields(schema, name, "CreationsInput", creations); } if (!replacements.isEmpty()) { inputFields(schema, name, "ReplacementsInput", replacements); } if (!additions.isEmpty()) { inputFields(schema, name, "AdditionsInput", additions); } if (!deletions.isEmpty()) { inputFields(schema, name, "DeletionsInput", deletions); } schema.append("type ").append(name).append("Mutations").append(" {\n"); if (!creations.isEmpty()) { schema.append(" create(").append("uri: String! ").append("entity: ").append(name).append("CreateInput!): ") .append(name).append(" @createMutation(dataSet: \"").append(rootType).append("\"") .append(" typeUri: \"").append(typeUri).append("\")").append("\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append(" edit(").append("uri: String! ").append("entity: ").append(name).append("EditInput!): ") .append(name).append(" @editMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } if (!deletions.isEmpty() && !hasCustomProvenance) { schema.append(" delete(").append("uri: String!): RemovedEntity! ") .append("@deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } else if (!deletions.isEmpty()) { schema.append(" delete(").append("uri: String! ").append("entity: ").append(name).append("DeleteInput): ") .append("RemovedEntity! @deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } schema.append(" persistEntity(").append("entityUri: String!): ").append("Message") .append(" @persistEntityMutation(dataSet: \"").append(rootType).append("\")").append("}\n"); return schema; } DerivedInputTypeSchemaGenerator(String typeUri, String rootType, GraphQlNameGenerator graphQlNameGenerator,
                                         DerivedSchemaContainer derivedSchemaContainer,
                                         ReadOnlyChecker readOnlyChecker, CustomProvenance customProvenance); void objectField(String description, Predicate predicate, String typeUri); void unionField(String description, Predicate predicate, Set<String> typeUris); void valueField(String description, Predicate predicate, String typeUri); StringBuilder getSchema(); void addMutationToSchema(StringBuilder schema); }
DerivedInputTypeSchemaGenerator { public StringBuilder getSchema() { StringBuilder schema = new StringBuilder(); if (creations.isEmpty() && additions.isEmpty() && deletions.isEmpty() && replacements.isEmpty()) { return schema; } String name = graphQlNameGenerator.createObjectTypeName(rootType, typeUri); if (!creations.isEmpty()) { schema.append("input ").append(name).append("CreateInput").append(" {\n"); schema.append(" creations: ").append(name).append("CreationsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append("input ").append(name).append("EditInput").append(" {\n"); if (!additions.isEmpty()) { schema.append(" additions: ").append(name).append("AdditionsInput\n"); } if (!deletions.isEmpty()) { schema.append(" deletions: ").append(name).append("DeletionsInput\n"); } schema.append(" replacements: ").append(name).append("ReplacementsInput\n"); if (hasCustomProvenance) { schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); } schema.append("}\n\n"); } if (!deletions.isEmpty() && hasCustomProvenance) { schema.append("input ").append(name).append("DeleteInput").append(" {\n"); schema.append(" provenance: ").append(rootType).append("ProvenanceInput\n"); schema.append("}\n\n"); } if (!creations.isEmpty()) { inputFields(schema, name, "CreationsInput", creations); } if (!replacements.isEmpty()) { inputFields(schema, name, "ReplacementsInput", replacements); } if (!additions.isEmpty()) { inputFields(schema, name, "AdditionsInput", additions); } if (!deletions.isEmpty()) { inputFields(schema, name, "DeletionsInput", deletions); } schema.append("type ").append(name).append("Mutations").append(" {\n"); if (!creations.isEmpty()) { schema.append(" create(").append("uri: String! ").append("entity: ").append(name).append("CreateInput!): ") .append(name).append(" @createMutation(dataSet: \"").append(rootType).append("\"") .append(" typeUri: \"").append(typeUri).append("\")").append("\n"); } if (!additions.isEmpty() || !deletions.isEmpty() || !replacements.isEmpty()) { schema.append(" edit(").append("uri: String! ").append("entity: ").append(name).append("EditInput!): ") .append(name).append(" @editMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } if (!deletions.isEmpty() && !hasCustomProvenance) { schema.append(" delete(").append("uri: String!): RemovedEntity! ") .append("@deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } else if (!deletions.isEmpty()) { schema.append(" delete(").append("uri: String! ").append("entity: ").append(name).append("DeleteInput): ") .append("RemovedEntity! @deleteMutation(dataSet: \"").append(rootType).append("\")").append("\n"); } schema.append(" persistEntity(").append("entityUri: String!): ").append("Message") .append(" @persistEntityMutation(dataSet: \"").append(rootType).append("\")").append("}\n"); return schema; } DerivedInputTypeSchemaGenerator(String typeUri, String rootType, GraphQlNameGenerator graphQlNameGenerator,
                                         DerivedSchemaContainer derivedSchemaContainer,
                                         ReadOnlyChecker readOnlyChecker, CustomProvenance customProvenance); void objectField(String description, Predicate predicate, String typeUri); void unionField(String description, Predicate predicate, Set<String> typeUris); void valueField(String description, Predicate predicate, String typeUri); StringBuilder getSchema(); void addMutationToSchema(StringBuilder schema);  }