Skip to content

Feature Request: Add documentation to initializer of generated Input Structs #562

@AnthonyMDev

Description

@AnthonyMDev

If our schema has an input data structure that has documentation for fields, that documentation is present in the generated swift structs above the fields. It would be nice if it was also added to the struct initializer. This would improve the Xcode inline documentation window usage for these input structs.

Example

Given this struct:

public struct MyInput: GraphQLMapConvertible {
  public var graphQLMap: GraphQLMap

  public init(contentId: GraphQLID, organizationId: GraphQLID) {
    graphQLMap = ["contentId": contentId, "workplaceId": workplaceId]
  }

  /// The ID of the content that is being created
  /// the top node, root of the content tree
  public var contentId: GraphQLID {
    get {
      return graphQLMap["contentId"] as! GraphQLID
    }
    set {
      graphQLMap.updateValue(newValue, forKey: "contentId")
    }
  }

  /// User's organization ID in this
  public var organizationId: GraphQLID {
    get {
      return graphQLMap["organizationId"] as! GraphQLID
    }
    set {
      graphQLMap.updateValue(newValue, forKey: "organizationId")
    }
  }
}

The schema field documentation would also exist for the init.

public struct MyInput: GraphQLMapConvertible {
  public var graphQLMap: GraphQLMap

  /// - Parameters:
  ///   - contentId: The ID of the content that is being created
  ///                the top node, root of the content tree
  ///   - workplaceId:  User's workplace ID in this
  public init(contentId: GraphQLID, organizationId: GraphQLID) {
    graphQLMap = ["contentId": contentId, "workplaceId": workplaceId]
  }

  /// Which page user donate (Campaign/ImpactFund/NpoPage)
  /// the top node, root of the content tree
  public var contentId: GraphQLID {
    get {
      return graphQLMap["contentId"] as! GraphQLID
    }
    set {
      graphQLMap.updateValue(newValue, forKey: "contentId")
    }
  }

  /// User's organization ID in this
  public var organizationId: GraphQLID {
    get {
      return graphQLMap["organizationId"] as! GraphQLID
    }
    set {
      graphQLMap.updateValue(newValue, forKey: "organizationId")
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenIssues related to or arising from code generationdocsFocuses on documentation changes

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions