use of com.graphql_java_generator.plugin.language.impl.InterfaceType in project graphql-maven-plugin-project by graphql-java-generator.
the class AddRelayConnections method addNodeInterface.
/**
* Adds the <I>Node</I> interfaces The <I>Node</I> is defined in the
* <A HREF="https://relay.dev/graphql/connections.htm">Relay Connection specification</A>. If a <I>Node</I>
* interface already exists in the schema, it is checked to be compliant to this specification. If not, an exception
* is thrown.
*
* @throws RuntimeException
* Thrown if a <I>Node</I> interface already exists, but is not compliant with the Relay Connection
* specification
*/
void addNodeInterface() {
final String NODE = "Node";
boolean found = false;
for (InterfaceType i : documentParser.getInterfaceTypes()) {
if (NODE.equals(i.getName())) {
// We've found it.
found = true;
// Let's check its properties
if (i.getMemberOfUnions().size() != 0) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (member of unions)");
}
if (i.getFields().size() != 1) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should contain exactly one field)");
}
if (!"id".equals(i.getFields().get(0).getName())) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should contain only the 'id' field)");
}
if (!"ID".equals(i.getFields().get(0).getGraphQLTypeSimpleName())) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should contain only the 'id' field, of the 'ID' type)");
}
if (!i.getFields().get(0).isId()) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should contain only the 'id' field, that is an identifier)");
}
if (i.getFields().get(0).getFieldTypeAST().getListDepth() > 0) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should contain only the 'id' field, that is not a list)");
}
if (!i.getFields().get(0).getFieldTypeAST().isMandatory()) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should contain only the 'id' field, that is mandatory)");
}
if (i.getRequestType() != null) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should not be a query/mutation/subscription)");
}
if (i.isInputType()) {
throw new RuntimeException("The " + NODE + " interface already exists, but is not compliant with the Relay specification (it should not be an input type)");
}
// Ok, this interface is compliant. We're done.
node = i;
break;
}
}
if (!found) {
// The interface Node has not been found. But this name can (and may not) be used for another type.
if (documentParser.getType(NODE, false) != null) {
throw new RuntimeException("A " + NODE + " type already exists. This prevents to create the " + NODE + " interface, as described in this article: https://dev.to/mikemarcacci/intermediate-interfaces-generic-utility-types-in-graphql-50e8");
}
// We're in the standard case: the interface doesn't exist in the given schema(s). Let's define it.
node = new InterfaceType(NODE, configuration, documentParser);
// Adding the id field toe the Node interface
FieldImpl f = FieldImpl.builder().name("id").owningType(node).documentParser(documentParser).fieldTypeAST(//
FieldTypeAST.builder().graphQLTypeSimpleName("ID").mandatory(true).build()).build();
node.getFields().add(f);
documentParser.getInterfaceTypes().add(node);
documentParser.getTypes().put(NODE, node);
}
}
use of com.graphql_java_generator.plugin.language.impl.InterfaceType in project graphql-maven-plugin-project by graphql-java-generator.
the class AddRelayConnections method addEdgeInterface.
/**
* Adds the <I>Edge</I> interface. The <I>Edge</I> is defined in the
* <A HREF="https://dev.to/mikemarcacci/intermediate-interfaces-generic-utility-types-in-graphql-50e8">generic
* utility types blog entry</A>, that leads to allow that an interface implements an interface in the GraphQL
* specification.If an <I>Edge</I> interface already exists in the schema, it is checked to be compliant to this
* specification. If not, an exception is thrown.
*
* @throws RuntimeException
* Thrown if a <I>Edge</I> interface already exists, but is not compliant with the specification
*/
void addEdgeInterface() {
final String EDGE = "Edge";
boolean found = false;
for (InterfaceType i : documentParser.getInterfaceTypes()) {
if (EDGE.equals(i.getName())) {
// We've found it.
found = true;
// Let's check its properties
if (i.getMemberOfUnions().size() != 0) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (member of unions)");
}
if (i.getRequestType() != null) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (it should not be a query/mutation/subscription)");
}
if (i.isInputType()) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (it should not be an input type)");
}
if (i.getFields().size() != 2) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (it should contain exactly two fields)");
}
// ///////////////////
// The cursor field
int j = 0;
if (!"cursor".equals(i.getFields().get(j).getName())) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the first field should be the 'cursor' field)");
}
if (!"String".equals(i.getFields().get(j).getGraphQLTypeSimpleName())) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'cursor' field should be a String field)");
}
if (i.getFields().get(j).isId()) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'cursor' field should not be an identifier)");
}
if (i.getFields().get(j).getFieldTypeAST().getListDepth() > 0) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'cursor' field should not be a list)");
}
if (!i.getFields().get(j).getFieldTypeAST().isMandatory()) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'cursor' field should be mandatory)");
}
// ///////////////////
// The node field
j += 1;
if (!"node".equals(i.getFields().get(j).getName())) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the second field should be the 'node' field)");
}
if (!"Node".equals(i.getFields().get(j).getGraphQLTypeSimpleName())) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'node' field should be of type [Edge])");
}
if (i.getFields().get(j).isId()) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'node' field should not be an identifier)");
}
if (i.getFields().get(j).getFieldTypeAST().getListDepth() > 0) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'node' field should not be a list)");
}
if (i.getFields().get(j).getFieldTypeAST().isMandatory()) {
throw new RuntimeException("The " + EDGE + " interface already exists, but is not compliant with the Relay specification (the 'node' field should not be mandatory)");
}
// Ok, this interface is compliant. We're done.
break;
}
}
if (!found) {
// The interface Edge has not been found. But this name can (and may not) be used for another type.
if (documentParser.getType(EDGE, false) != null) {
throw new RuntimeException("A " + EDGE + " type already exists. This prevents to create the " + EDGE + " interface, as described in this article: https://dev.to/mikemarcacci/intermediate-interfaces-generic-utility-types-in-graphql-50e8");
}
// We're in the standard case: the interface doesn't exist in the given schema(s). Let's define it.
InterfaceType i = new InterfaceType(EDGE, configuration, documentParser);
// Adding the id field toe the Node interface
FieldImpl cursor = FieldImpl.builder().name("cursor").owningType(i).documentParser(documentParser).fieldTypeAST(//
FieldTypeAST.builder().graphQLTypeSimpleName("String").mandatory(true).build()).build();
FieldImpl node = FieldImpl.builder().name("node").owningType(i).documentParser(documentParser).fieldTypeAST(//
FieldTypeAST.builder().graphQLTypeSimpleName("Node").build()).build();
i.getFields().add(cursor);
i.getFields().add(node);
documentParser.getInterfaceTypes().add(i);
documentParser.getTypes().put(EDGE, i);
}
}
use of com.graphql_java_generator.plugin.language.impl.InterfaceType in project graphql-maven-plugin-project by graphql-java-generator.
the class GenerateCodeDocumentParser method addTypeAnnotationForClientMode.
/**
* This method add the needed annotation(s) to the given type, when in client mode
*
* @param type
*/
void addTypeAnnotationForClientMode(Type type) {
if (type instanceof InterfaceType || type instanceof UnionType) {
if (configuration.isGenerateJacksonAnnotations()) {
type.addImport(configuration.getPackageName(), JsonTypeInfo.class.getName());
type.addImport(configuration.getPackageName(), JsonTypeInfo.Id.class.getName());
type.addAnnotation("@JsonTypeInfo(use = Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = \"__typename\", visible = true)");
// jsonSubTypes annotation looks like this:
// @JsonSubTypes({ @Type(value = Droid.class, name = "Droid"), @Type(value = Human.class, name =
// "Human") })
StringBuffer jsonSubTypes = new StringBuffer();
type.addImport(configuration.getPackageName(), JsonSubTypes.class.getName());
type.addImport(configuration.getPackageName(), JsonSubTypes.Type.class.getName());
jsonSubTypes.append("@JsonSubTypes({");
boolean addSeparator = false;
List<ObjectType> types;
if (type instanceof InterfaceType)
types = ((InterfaceType) type).getImplementingTypes();
else
types = ((UnionType) type).getMemberTypes();
for (ObjectType t : types) {
// No separator for the first iteration
if (addSeparator)
jsonSubTypes.append(",");
else
addSeparator = true;
jsonSubTypes.append(" @Type(value = ").append(t.getName()).append(".class, name = \"").append(t.getName()).append("\")");
}
jsonSubTypes.append(" })");
type.addAnnotation(jsonSubTypes.toString());
}
}
// query/mutation/subscription
if (type instanceof ObjectType && ((ObjectType) type).getRequestType() != null) {
type.addImport(configuration.getPackageName(), GraphQLQuery.class.getName());
type.addImport(configuration.getPackageName(), RequestType.class.getName());
type.addAnnotation("@GraphQLQuery(name = \"" + type.getName() + "\", type = RequestType." + ((ObjectType) type).getRequestType() + ")");
}
// Let's add the annotations, that are common to both the client and the server mode
addTypeAnnotationForBothClientAndServerMode(type);
}
use of com.graphql_java_generator.plugin.language.impl.InterfaceType in project graphql-maven-plugin-project by graphql-java-generator.
the class GenerateCodeDocumentParser method addIntrospectionCapabilities.
/**
* Add introspection capabilities: the __schema and __type query into a dedicated __IntrospectionQuery, and the
* __typename into each GraphQL object.<BR/>
* Note: the introspection schema has already been parsed, as it is added by {@link ResourceSchemaStringProvider} in
* the documents list
*/
void addIntrospectionCapabilities() {
// No action in server mode: everything is handled by graphql-java
if (configuration.getMode().equals(PluginMode.client)) {
logger.debug("Adding introspection capability");
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (queryType == null) {
logger.debug("The source schema contains no query: creating an empty query type");
// There was no query. We need to create one. It will contain only the Introspection Query
queryType = new ObjectType(DEFAULT_QUERY_NAME, configuration, this);
queryType.setName(INTROSPECTION_QUERY);
queryType.setRequestType("query");
// Let's first add the regular object that'll receive the server response (in the default package)
getObjectTypes().add(queryType);
types.put(queryType.getName(), queryType);
}
// We also need to add the relevant fields into the regular object that matches the query.
Type objectQuery = getType(queryType.getName());
objectQuery.getFields().add(get__SchemaField(objectQuery));
objectQuery.getFields().add(get__TypeField(objectQuery));
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Second step: add the __datatype field into every GraphQL type (out of input types)
// That is : in all regular object types and interfaces.
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
logger.debug("Adding __typename to each object");
for (ObjectType type : getObjectTypes()) {
if (!type.isInputType()) {
type.getFields().add(FieldImpl.builder().documentParser(this).name("__typename").fieldTypeAST(FieldTypeAST.builder().graphQLTypeSimpleName("String").mandatory(false).build()).owningType(type).build());
}
}
logger.debug("Adding __typename to each interface");
for (InterfaceType type : interfaceTypes) {
type.getFields().add(FieldImpl.builder().documentParser(this).name("__typename").fieldTypeAST(FieldTypeAST.builder().graphQLTypeSimpleName("String").mandatory(false).build()).owningType(type).build());
}
}
}
use of com.graphql_java_generator.plugin.language.impl.InterfaceType in project graphql-maven-plugin-project by graphql-java-generator.
the class DocumentParser_allGraphQLCases_Server_Test method test_parseOneDocument_allGraphQLCases.
@Test
@Execution(ExecutionMode.CONCURRENT)
void test_parseOneDocument_allGraphQLCases() throws IOException {
// Go, go, go
int i = generateCodeDocumentParser.parseDocuments();
// Verification
assertEquals(44, i, "Nb java files are generated");
assertEquals(8, generateCodeDocumentParser.getDirectives().size(), "Nb directives");
assertEquals(27, generateCodeDocumentParser.getObjectTypes().size(), "Nb objects");
assertEquals(5, generateCodeDocumentParser.getCustomScalars().size(), "Nb custom scalars");
assertEquals(14, generateCodeDocumentParser.getInterfaceTypes().size(), "Nb interfaces");
assertEquals(3, generateCodeDocumentParser.getEnumTypes().size(), "Nb enums");
assertNotNull(generateCodeDocumentParser.getQueryType(), "One query");
assertNotNull(generateCodeDocumentParser.getMutationType(), "One mutation");
assertNotNull(generateCodeDocumentParser.getSubscriptionType(), "One subscription");
assertEquals("query", generateCodeDocumentParser.getQueryType().getRequestType());
assertEquals("mutation", generateCodeDocumentParser.getMutationType().getRequestType());
assertEquals("subscription", generateCodeDocumentParser.getSubscriptionType().getRequestType());
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DataFetcherImpl dataFetcher = findDataFetcher("DataFetchersDelegateAllFieldCases", "oneWithIdSubType", 1);
assertTrue(dataFetcher.isCompletableFuture(), "oneWithIdSubType: the dataLoader one");
//
dataFetcher = findDataFetcher("DataFetchersDelegateAllFieldCases", "listWithIdSubTypes", 1);
assertFalse(dataFetcher.isCompletableFuture(), "listWithIdSubTypes (only standard dataFethcher here)");
//
dataFetcher = findDataFetcher("DataFetchersDelegateAllFieldCases", "oneWithoutIdSubType", 1);
assertFalse(dataFetcher.isCompletableFuture(), "oneWithoutIdSubType (only standard dataFethcher here)");
//
dataFetcher = findDataFetcher("DataFetchersDelegateAllFieldCases", "listWithoutIdSubTypes", 1);
assertFalse(dataFetcher.isCompletableFuture(), "listWithoutIdSubTypes (only standard dataFethcher here)");
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Checks if input types for the AllFieldCases object are correctly read
//
ObjectType objectType = (ObjectType) generateCodeDocumentParser.getType("AllFieldCases");
int j = 0;
// checkField(type, j, name, list, mandatory, itemMandatory, typeName, classname)
// checkInputParameter(type, j, numParam, name, list, mandatory, itemMandatory, typeName, classname,
// defaultValue)
//
// id: ID!
checkField(objectType, j, "id", 0, true, null, "ID", "UUID");
checkNbInputParameter(objectType, j, 0);
j += 1;
// name: String!
checkField(objectType, j, "name", 0, true, null, "String", "String");
checkNbInputParameter(objectType, j, 0);
j += 1;
// forname(uppercase: Boolean, textToAppendToTheForname: String): String
checkField(objectType, j, "forname", 0, false, null, "String", "String");
checkNbInputParameter(objectType, j, 2);
checkInputParameter(objectType, j, 0, "uppercase", 0, false, null, "Boolean", "Boolean", null);
checkInputParameter(objectType, j, 1, "textToAppendToTheForname", 0, false, null, "String", "String", null);
j += 1;
// age: Long!
checkField(objectType, j, "age", 0, true, null, "Long", "Long");
checkNbInputParameter(objectType, j, 1);
checkInputParameter(objectType, j, 0, "unit", 0, false, null, "Unit", "Unit", new graphql.language.EnumValue("YEAR"));
j += 1;
// aFloat: Float
checkField(objectType, j, "aFloat", 0, false, null, "Float", "Double");
checkNbInputParameter(objectType, j, 0);
j += 1;
// date: Date
checkField(objectType, j, "date", 0, false, null, "Date", "Date");
checkNbInputParameter(objectType, j, 0);
j += 1;
// dateTime: DateTime
checkField(objectType, j, "dateTime", 0, false, null, "DateTime", "OffsetDateTime");
checkNbInputParameter(objectType, j, 0);
j += 1;
// dates: [Date]!
checkField(objectType, j, "dates", 1, true, false, "Date", "Date");
checkNbInputParameter(objectType, j, 0);
j += 1;
// nbComments: Int
checkField(objectType, j, "nbComments", 0, false, null, "Int", "Integer");
checkNbInputParameter(objectType, j, 0);
j += 1;
// comments: [String]
checkField(objectType, j, "comments", 1, false, false, "String", "String");
checkNbInputParameter(objectType, j, 0);
j += 1;
// booleans: [Boolean!]
checkField(objectType, j, "booleans", 1, false, true, "Boolean", "Boolean");
checkNbInputParameter(objectType, j, 0);
j += 1;
// aliases: [String]!
checkField(objectType, j, "aliases", 1, true, false, "String", "String");
checkNbInputParameter(objectType, j, 0);
j += 1;
// planets: [String!]!
checkField(objectType, j, "planets", 1, true, true, "String", "String");
checkNbInputParameter(objectType, j, 0);
j += 1;
// friends: [Human!]
checkField(objectType, j, "friends", 1, false, true, "Human", "Human");
checkNbInputParameter(objectType, j, 0);
j += 1;
// matrix: [[Float]]!
checkField(objectType, j, "matrix", 2, true, false, "Float", "Double");
checkNbInputParameter(objectType, j, 0);
j += 1;
// oneWithIdSubType: AllFieldCasesWithIdSubtype
checkField(objectType, j, "oneWithIdSubType", 0, false, null, "AllFieldCasesWithIdSubtype", "AllFieldCasesWithIdSubtype");
checkNbInputParameter(objectType, j, 1);
checkInputParameter(objectType, j, 0, "uppercase", 0, false, null, "Boolean", "Boolean", null);
j += 1;
// listWithIdSubTypes(nbItems: Long!, date: Date, dates: [Date]!, uppercaseName: Boolean,
// textToAppendToTheForname: String): [AllFieldCasesWithIdSubtype]
checkField(objectType, j, "listWithIdSubTypes", 1, false, false, "AllFieldCasesWithIdSubtype", "AllFieldCasesWithIdSubtype");
checkNbInputParameter(objectType, j, 5);
checkInputParameter(objectType, j, 0, "nbItems", 0, true, null, "Long", "Long", null);
checkInputParameter(objectType, j, 1, "date", 0, false, null, "Date", "Date", null);
checkInputParameter(objectType, j, 2, "dates", 1, true, false, "Date", "Date", null);
checkInputParameter(objectType, j, 3, "uppercaseName", 0, false, null, "Boolean", "Boolean", null);
checkInputParameter(objectType, j, 4, "textToAppendToTheForname", 0, false, null, "String", "String", null);
j += 1;
// oneWithoutIdSubType(input: FieldParameterInput): AllFieldCasesWithoutIdSubtype
checkField(objectType, j, "oneWithoutIdSubType", 0, false, false, "AllFieldCasesWithoutIdSubtype", "AllFieldCasesWithoutIdSubtype");
checkNbInputParameter(objectType, j, 1);
checkInputParameter(objectType, j, 0, "input", 0, false, null, "FieldParameterInput", "FieldParameterInput", null);
j += 1;
// listWithoutIdSubTypes(nbItems: Int!, input: FieldParameterInput, textToAppendToTheForname: String):
// [AllFieldCasesWithoutIdSubtype]
checkField(objectType, j, "listWithoutIdSubTypes", 1, false, false, "AllFieldCasesWithoutIdSubtype", "AllFieldCasesWithoutIdSubtype");
checkNbInputParameter(objectType, j, 3);
checkInputParameter(objectType, j, 0, "nbItems", 0, true, null, "Long", "Long", null);
checkInputParameter(objectType, j, 1, "input", 0, false, null, "FieldParameterInput", "FieldParameterInput", null);
checkInputParameter(objectType, j, 2, "textToAppendToTheForname", 0, false, null, "String", "String", null);
j += 1;
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Checks of type implementing multiples interfaces
objectType = (ObjectType) generateCodeDocumentParser.getType("Human");
//
assertEquals(4, objectType.getImplementz().size());
assertTrue(objectType.getImplementz().contains("Character"));
assertTrue(objectType.getImplementz().contains("Commented"));
assertTrue(objectType.getImplementz().contains("WithID"));
// This is an union
assertTrue(objectType.getImplementz().contains("AnyCharacter"));
//
InterfaceType interfaceType = (InterfaceType) generateCodeDocumentParser.getType("WithID");
assertEquals(4, interfaceType.getImplementingTypes().size());
j = 0;
assertEquals("AllFieldCases", interfaceType.getImplementingTypes().get(j++).getName());
assertEquals("AllFieldCasesInterfaceType", interfaceType.getImplementingTypes().get(j++).getName());
assertEquals("Human", interfaceType.getImplementingTypes().get(j++).getName());
assertEquals("Droid", interfaceType.getImplementingTypes().get(j++).getName());
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Checks of directive parsing
i = 0;
assertEquals("skip", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("include", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("defer", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("deprecated", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("IDScalarDirective", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("RelayConnection", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("testDirective", generateCodeDocumentParser.getDirectives().get(i++).getName());
assertEquals("anotherTestDirective", generateCodeDocumentParser.getDirectives().get(i++).getName());
// On Scalar
assertEquals(0, generateCodeDocumentParser.getType("Date").getAppliedDirectives().size(), "No directive in the schema, as it is adapted for graphql-java v15.0, see below in the junit test code");
// The next test is deactivated, because of a bug in graphql-java v15.0. It should be restored, once the issue
// 2055 is solved
// checkDirectivesOnType(generateCodeDocumentParser.getType("Date"), true, "on Scalar", null, null, null, null,
// null,
// null, null, true);
checkDirectivesOnType(generateCodeDocumentParser.getType("Long"), false, null, null, null, null, null, null, null, null, false);
// On schema
// Currently not managed (schema is not stored, and no java classes is generated afteward for the schema)
// On enum
assertEquals(0, generateCodeDocumentParser.getType("Episode").getAppliedDirectives().size(), "No directive in the schema, as it is adapted for graphql-java v15.0, see below in the junit test code");
// The next test is deactivated, because of a bug in graphql-java v15.0. It should be restored, once the issue
// 2055 is solved
// checkDirectivesOnType(generateCodeDocumentParser.getType("Episode"), true, "on Enum", "69", 666, (float)
// 666.666,
// true, "00000000-0000-0000-0000-000000000002", null, "2001-02-28", false);
checkDirectivesOnType(generateCodeDocumentParser.getType("Unit"), false, null, null, null, null, null, null, null, null, false);
// On enum item
// The 3 below tests should be removed, and 3 next be uncommented, once the graphqm-java's issue 2055 is solved
checkDirectivesOnEnumValue(generateCodeDocumentParser.getType("Episode"), "DOES_NOT_EXIST", false, "on Enum", "-1", false);
checkDirectivesOnEnumValue(generateCodeDocumentParser.getType("Episode"), "JEDI", false, null, null, false);
checkDirectivesOnEnumValue(generateCodeDocumentParser.getType("Episode"), "EMPIRE", false, null, null, false);
// The next 3 tests are deactivated, because of a bug in graphql-java v15.0. It should be restored, once the
// issue 2055 is solved
// checkDirectivesOnEnumValue(generateCodeDocumentParser.getType("Episode"), "DOES_NOT_EXIST", true, "on Enum",
// "-1",
// true);
// checkDirectivesOnEnumValue(generateCodeDocumentParser.getType("Episode"), "JEDI", false, null, null, false);
// checkDirectivesOnEnumValue(generateCodeDocumentParser.getType("Episode"), "EMPIRE", false, null, null, true);
// On interface
checkDirectivesOnType(generateCodeDocumentParser.getType("WithID"), true, "on Interface", "666", null, null, null, null, null, null, false);
checkDirectivesOnType(generateCodeDocumentParser.getType("Character"), true, "on Character interface", null, null, null, null, null, null, null, true);
// On interface field
checkDirectivesOnField(generateCodeDocumentParser.getType("Character"), "name", true, "on interface field", null, true, 0);
checkDirectivesOnField(generateCodeDocumentParser.getType("Character"), "appearsIn", false, null, null, true, 0);
// On union
// checkDirectivesOnType(documentParser.getType("AnyCharacter"), true, "on Union", null, false);
// On input type
checkDirectivesOnType(generateCodeDocumentParser.getType("AllFieldCasesInput"), true, "on Input Type", null, null, null, null, null, null, null, false);
// On input type field
checkDirectivesOnField(generateCodeDocumentParser.getType("AllFieldCasesInput"), "id", true, "on Input Field", null, false, 0);
checkDirectivesOnField(generateCodeDocumentParser.getType("AllFieldCasesInput"), "name", false, null, null, false, 0);
// On type
checkDirectivesOnType(generateCodeDocumentParser.getType("AllFieldCases"), true, "on Object", null, null, null, null, null, null, null, true);
// On type field
checkDirectivesOnField(generateCodeDocumentParser.getType("AllFieldCases"), "id", true, "on Field", null, false, 0);
checkDirectivesOnField(generateCodeDocumentParser.getType("AllFieldCases"), "name", false, null, null, false, 0);
// On input parameter
checkDirectivesOnInputParameter(generateCodeDocumentParser.getType("AllFieldCases"), "forname", "uppercase", true, "on Argument", null, false);
checkDirectivesOnInputParameter(generateCodeDocumentParser.getType("AllFieldCases"), "forname", "textToAppendToTheForname", false, null, null, false);
}
Aggregations