graphql.language.InputObjectTypeDefinition Java Examples
The following examples show how to use
graphql.language.InputObjectTypeDefinition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GqlParentType.java From manifold with Apache License 2.0 | 6 votes |
private List<? extends NamedNode> getDefinitions( Definition def ) { if( def instanceof OperationDefinition ) { return ((OperationDefinition)def).getVariableDefinitions(); } if( def instanceof InputObjectTypeDefinition ) { return ((InputObjectTypeDefinition)def).getInputValueDefinitions(); } if( def instanceof ObjectTypeDefinition ) { return ((ObjectTypeDefinition)def).getFieldDefinitions(); } throw new IllegalStateException(); }
Example #2
Source File: GqlParentType.java From manifold with Apache License 2.0 | 6 votes |
private void addInnerInputType( InputObjectTypeDefinition type, SrcLinkedClass enclosingType ) { String identifier = makeIdentifier( type.getName(), false ); String fqn = getFqn() + '.' + identifier; SrcLinkedClass srcClass = new SrcLinkedClass( fqn, enclosingType, Interface ) .addInterface( IJsonBindingsBacked.class.getSimpleName() ) .addAnnotation( new SrcAnnotationExpression( Structural.class.getSimpleName() ) .addArgument( "factoryClass", Class.class, identifier + ".ProxyFactory.class" ) ) .modifiers( Modifier.PUBLIC ); addUnionInterfaces( type, srcClass ); addActualNameAnnotation( srcClass, type.getName(), false ); addSourcePositionAnnotation( srcClass, type, srcClass ); addProxyFactory( srcClass ); addBuilder( srcClass, type ); addCreateMethod( srcClass, type ); addBuilderMethod( srcClass, type ); List<InputValueDefinition> inputValueDefinitions = type.getInputValueDefinitions(); for( InputValueDefinition member: inputValueDefinitions ) { addMember( srcClass, member, name -> inputValueDefinitions.stream().anyMatch( f -> f.getName().equals( name ) ) ); } addInputExtensions( type, srcClass ); enclosingType.addInnerClass( srcClass ); }
Example #3
Source File: GqlParentType.java From manifold with Apache License 2.0 | 6 votes |
private void addInputExtensions( InputObjectTypeDefinition type, SrcLinkedClass srcClass ) { List<InputValueDefinition> baseInputValueDefinitions = type.getInputValueDefinitions(); List<InputObjectTypeExtensionDefinition> inputExtensions = _registry.inputObjectTypeExtensions().get( type.getName() ); if( inputExtensions != null ) { for( InputObjectTypeExtensionDefinition ext: inputExtensions ) { List<InputValueDefinition> extInputValueDefinitions = ext.getInputValueDefinitions(); for( InputValueDefinition member: extInputValueDefinitions ) { addMember( srcClass, member, name -> baseInputValueDefinitions.stream().anyMatch( f -> f.getName().equals( name ) ) || extInputValueDefinitions.stream().anyMatch( f -> f.getName().equals( name ) ) ); } } } }
Example #4
Source File: TypeEntry.java From graphql-apigen with Apache License 2.0 | 6 votes |
private static List<Directive> getDirectives(Definition def) { if ( def instanceof ObjectTypeDefinition ) { return ((ObjectTypeDefinition)def).getDirectives(); } if ( def instanceof InterfaceTypeDefinition ) { return ((InterfaceTypeDefinition)def).getDirectives(); } if ( def instanceof EnumTypeDefinition ) { return ((EnumTypeDefinition)def).getDirectives(); } if ( def instanceof ScalarTypeDefinition ) { return ((ScalarTypeDefinition)def).getDirectives(); } if ( def instanceof UnionTypeDefinition ) { return ((UnionTypeDefinition)def).getDirectives(); } if ( def instanceof InputObjectTypeDefinition ) { return ((InputObjectTypeDefinition)def).getDirectives(); } if ( def instanceof SchemaDefinition ) { return ((SchemaDefinition)def).getDirectives(); } return Collections.emptyList(); }
Example #5
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 6 votes |
public synchronized List<String> getImports() { if ( null == imports ) { Definition def = typeEntry.getDefinition(); Set<String> names = new TreeSet<String>(); if ( isObjectType() ) { addImports(names, (ObjectTypeDefinition)def); } else if ( isInterfaceType() ) { addImports(names, (InterfaceTypeDefinition)def); } else if ( isInputObjectType() ) { addImports(names, (InputObjectTypeDefinition)def); } else if ( isUnionType() ) { addImports(names, (UnionTypeDefinition)def); } else if ( isEnumType() ) { addImports(names, (EnumTypeDefinition)def); } else if ( isSchemaType() ) { addImports(names, (SchemaDefinition)def); } imports = new ArrayList<>(names); } return imports; }
Example #6
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 6 votes |
public synchronized List<Field> getFields() { if ( null == fields ) { Definition def = typeEntry.getDefinition(); if ( isObjectType() ) { fields = getFields((ObjectTypeDefinition)def); } else if ( isInterfaceType() ) { fields = getFields((InterfaceTypeDefinition)def); } else if ( isInputObjectType() ) { fields = getFields((InputObjectTypeDefinition)def); } else if ( isUnionType() ) { fields = getFields((UnionTypeDefinition)def); } else if ( isEnumType() ) { fields = getFields((EnumTypeDefinition)def); } else if ( isSchemaType() ) { fields = getFields((SchemaDefinition)def); } else { fields = Collections.emptyList(); } } return fields; }
Example #7
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
private void addInnerTypes( SrcLinkedClass srcClass ) { mapUnionMemberToUnions(); for( TypeDefinition type: _registry.types().values() ) { if( type instanceof ObjectTypeDefinition ) { addInnerObjectType( (ObjectTypeDefinition)type, srcClass ); } else if( type instanceof InterfaceTypeDefinition ) { addInnerInterfaceType( (InterfaceTypeDefinition)type, srcClass ); } else if( type instanceof EnumTypeDefinition ) { addInnerEnumType( (EnumTypeDefinition)type, srcClass ); } else if( type instanceof InputObjectTypeDefinition ) { addInnerInputType( (InputObjectTypeDefinition)type, srcClass ); } else if( type instanceof UnionTypeDefinition ) { addInnerUnionType( (UnionTypeDefinition)type, srcClass ); } } }
Example #8
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") private String getStartSymbol( Node node ) { String start = ""; if( node instanceof TypeDefinition ) { if( node instanceof ObjectTypeDefinition ) { start = "type"; } else if( node instanceof EnumTypeDefinition ) { start = "enum"; } else if( node instanceof InputObjectTypeDefinition ) { start = "input"; } else if( node instanceof InterfaceTypeDefinition ) { start = "interface"; } else if( node instanceof ScalarTypeDefinition ) { start = "scalar"; } else if( node instanceof UnionTypeDefinition ) { start = "union"; } } else if( node instanceof OperationDefinition ) { start = ((OperationDefinition)node).getOperation().name().toLowerCase(); } return start; }
Example #9
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 5 votes |
private List<Field> getFields(InputObjectTypeDefinition def) { List<Field> fields = new ArrayList<Field>(); for ( InputValueDefinition fieldDef : def.getInputValueDefinitions() ) { Field field = new Field(fieldDef.getName(), toJavaTypeName(fieldDef.getType())); field.graphQLType = toGraphQLType(fieldDef.getType()); field.defaultValue = toJavaValue(fieldDef.getDefaultValue()); fields.add(field); } return fields; }
Example #10
Source File: GraphQLIntrospectionResultToSchema.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@SuppressWarnings("unchecked") InputObjectTypeDefinition createInputObject(Map<String, Object> input) { assertTrue(input.get("kind").equals("INPUT_OBJECT"), () -> "wrong input"); final List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("inputFields"); final InputObjectTypeDefinition inputObjectTypeDefinition = InputObjectTypeDefinition.newInputObjectDefinition() .name((String) input.get("name")) .description(getDescription(input)) .inputValueDefinitions(createInputValueDefinitions(fields)) .build(); return inputObjectTypeDefinition; }
Example #11
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 4 votes |
public boolean isInputObjectType() { return typeEntry.getDefinition() instanceof InputObjectTypeDefinition; }
Example #12
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 4 votes |
private void addImports(Collection<String> imports, InputObjectTypeDefinition def) { for ( InputValueDefinition fieldDef : def.getInputValueDefinitions() ) { addImports(imports, fieldDef.getType()); } }