graphql.language.InputValueDefinition Java Examples
The following examples show how to use
graphql.language.InputValueDefinition.
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 Type getType( Node def ) { if( def instanceof VariableDefinition ) { return ((VariableDefinition)def).getType(); } if( def instanceof InputValueDefinition ) { return ((InputValueDefinition)def).getType(); } if( def instanceof FieldDefinition ) { return ((FieldDefinition)def).getType(); } 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: GraphQLIntrospectionResultToSchema.java From js-graphql-intellij-plugin with MIT License | 6 votes |
private List<FieldDefinition> createFields(List<Map<String, Object>> fields) { List<FieldDefinition> result = new ArrayList<>(); for (Map<String, Object> field : fields) { List<Map<String, Object>> args = (List<Map<String, Object>>) field.get("args"); List<InputValueDefinition> inputValueDefinitions = createInputValueDefinitions(args); FieldDefinition fieldDefinition = FieldDefinition.newFieldDefinition() .name((String) field.get("name")) .description(getDescription(field)) .type(createTypeIndirection((Map<String, Object>) field.get("type"))) .inputValueDefinitions(inputValueDefinitions) .directives(createDeprecatedDirective(field)) .build(); result.add(fieldDefinition); } return result; }
Example #5
Source File: GraphQLIntrospectionResultToSchema.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@SuppressWarnings("unchecked") private List<InputValueDefinition> createInputValueDefinitions(List<Map<String, Object>> args) { List<InputValueDefinition> result = new ArrayList<>(); for (Map<String, Object> arg : args) { Type argType = createTypeIndirection((Map<String, Object>) arg.get("type")); String valueLiteral = (String) arg.get("defaultValue"); Value defaultValue = valueLiteral != null ? AstValueHelper.valueFromAst(valueLiteral) : null; InputValueDefinition inputValueDefinition = InputValueDefinition.newInputValueDefinition() .name((String) arg.get("name")) .type(argType) .description(getDescription(arg)) .defaultValue(defaultValue) .build(); result.add(inputValueDefinition); } return result; }
Example #6
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 #7
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 5 votes |
private List<Arg> toArgs(List<InputValueDefinition> defs) { List<Arg> result = new ArrayList<>(); for ( InputValueDefinition def : defs ) { Arg arg = new Arg(def.getName(), toJavaTypeName(def.getType())); arg.graphQLType = toGraphQLType(def.getType()); arg.defaultValue = toJavaValue(def.getDefaultValue()); result.add(arg); } return result; }
Example #8
Source File: GqlParentType.java From manifold with Apache License 2.0 | 4 votes |
private void addMember( SrcLinkedClass srcClass, InputValueDefinition member, Predicate<String> duplicateChecker ) { Type type = member.getType(); String name = makeIdentifier( member.getName(), false ); addMember( srcClass, member, type, name, duplicateChecker ); }
Example #9
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()); } }