这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@cocoahero
Copy link
Contributor

This PR modifies the tool to add support for generating QUERY and MUTATION directives.

Summary of Changes

  • Adds abstract Directive class.
  • Modifies APISchema.java.erb template to generate overloaded versions of the query and mutation methods that accept a List<Directive>.
  • Modifies the default query and mutation serialization to ensure it is prefixed with the operation type.

Generated Example

/**
* An example directive.
*/
public static class MyDirective extends Directive {
    public AnEnumeratedArgument myArgument;

    public MyDirective() {
        super("myDirective");
    }

    @Override
    public String toString() {
        StringBuilder _queryBuilder = new StringBuilder(super.toString());
        _queryBuilder.append("(");

        if (myArgument != null) {
            _queryBuilder.append("myArgument:");
            _queryBuilder.append(myArgument.toString());
        }

        _queryBuilder.append(")");
        return _queryBuilder.toString();
    }
}

@cocoahero cocoahero self-assigned this Jun 15, 2021
Copy link
Contributor

@eapache eapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been ages since I've looked at any of this stuff, but it makes sense to me.

@cocoahero cocoahero merged commit 295f0e2 into master Jun 16, 2021
@cocoahero cocoahero deleted the support-query-directives branch June 16, 2021 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants