Java Code Examples for graphql.language.ObjectTypeDefinition#getFieldDefinitions()

The following examples show how to use graphql.language.ObjectTypeDefinition#getFieldDefinitions() . 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 vote down vote up
private void addObjectExtensions( ObjectTypeDefinition type, SrcLinkedClass srcClass )
{
  List<FieldDefinition> baseFieldDefinitions = type.getFieldDefinitions();
  List<ObjectTypeExtensionDefinition> objectExtensions = _registry.objectTypeExtensions().get( type.getName() );
  if( objectExtensions != null )
  {
    for( ObjectTypeExtensionDefinition ext: objectExtensions )
    {
      List<FieldDefinition> extFieldDefinitions = ext.getFieldDefinitions();
      for( FieldDefinition member: extFieldDefinitions )
      {
        addMember( srcClass, member,
          name ->
            baseFieldDefinitions.stream().anyMatch( f -> f.getName().equals( name ) ) ||
            extFieldDefinitions.stream().anyMatch( f -> f.getName().equals( name ) )
        );
      }
    }
  }
}
 
Example 2
Source File: GqlParentType.java    From manifold with Apache License 2.0 5 votes vote down vote up
private void addInnerObjectType( ObjectTypeDefinition 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 );
  List<Type> interfaces = type.getImplements();
  addInterfaces( srcClass, interfaces );
  addProxyFactory( srcClass );
  addBuilder( srcClass, type );
  addCreateMethod( srcClass, type );
  addBuilderMethod( srcClass, type );
  addLoadMethod( srcClass );
  addCopier( srcClass, type );
  addCopierMethod( srcClass );
  addCopyMethod( srcClass );

  List<FieldDefinition> fieldDefinitions = type.getFieldDefinitions();
  for( FieldDefinition member: fieldDefinitions )
  {
    addMember( srcClass, member, name -> fieldDefinitions.stream().anyMatch( f -> f.getName().equals( name ) ) );
  }
  addObjectExtensions( type, srcClass );
  enclosingType.addInnerClass( srcClass );
}
 
Example 3
Source File: STModel.java    From graphql-apigen with Apache License 2.0 5 votes vote down vote up
private List<Field> getFields(ObjectTypeDefinition def) {
    List<Field> fields = new ArrayList<Field>();
    for ( FieldDefinition fieldDef : def.getFieldDefinitions() ) {
        Field field = new Field(fieldDef.getName(), toJavaTypeName(fieldDef.getType()));
        field.graphQLType = toGraphQLType(fieldDef.getType());
        field.dataResolver = toDataResolver(fieldDef.getType());
        field.args = toArgs(fieldDef.getInputValueDefinitions());
        fields.add(field);
    }
    return fields;
}
 
Example 4
Source File: STModel.java    From graphql-apigen with Apache License 2.0 4 votes vote down vote up
private void addImports(Collection<String> imports, ObjectTypeDefinition def) {
    for ( FieldDefinition fieldDef : def.getFieldDefinitions() ) {
        addImports(imports, fieldDef.getType());
    }
}