2021-01-16 06:36:44 +00:00
|
|
|
package spec
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/fatih/camelcase"
|
|
|
|
"github.com/sunboyy/repogen/internal/code"
|
|
|
|
)
|
|
|
|
|
2021-01-21 11:56:30 +00:00
|
|
|
// ParseInterfaceMethod returns repository method spec from declared interface method
|
2021-03-03 14:01:32 +00:00
|
|
|
func ParseInterfaceMethod(structs code.Structs, structModel code.Struct, method code.Method) (MethodSpec, error) {
|
2021-01-21 11:56:30 +00:00
|
|
|
parser := interfaceMethodParser{
|
2021-03-03 14:01:32 +00:00
|
|
|
fieldResolver: fieldResolver{
|
|
|
|
Structs: structs,
|
|
|
|
},
|
2021-01-16 06:36:44 +00:00
|
|
|
StructModel: structModel,
|
2021-01-21 11:56:30 +00:00
|
|
|
Method: method,
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return parser.Parse()
|
|
|
|
}
|
|
|
|
|
2021-01-21 11:56:30 +00:00
|
|
|
type interfaceMethodParser struct {
|
2021-03-03 14:01:32 +00:00
|
|
|
fieldResolver fieldResolver
|
|
|
|
StructModel code.Struct
|
|
|
|
Method code.Method
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-01-21 11:56:30 +00:00
|
|
|
func (p interfaceMethodParser) Parse() (MethodSpec, error) {
|
2021-02-07 05:51:51 +00:00
|
|
|
operation, err := p.parseMethod()
|
|
|
|
if err != nil {
|
|
|
|
return MethodSpec{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return MethodSpec{
|
|
|
|
Name: p.Method.Name,
|
|
|
|
Params: p.Method.Params,
|
|
|
|
Returns: p.Method.Returns,
|
|
|
|
Operation: operation,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p interfaceMethodParser) parseMethod() (Operation, error) {
|
2021-01-21 11:56:30 +00:00
|
|
|
methodNameTokens := camelcase.Split(p.Method.Name)
|
2021-01-16 06:36:44 +00:00
|
|
|
switch methodNameTokens[0] {
|
2021-02-01 14:39:20 +00:00
|
|
|
case "Insert":
|
2021-02-07 05:51:51 +00:00
|
|
|
return p.parseInsertOperation(methodNameTokens[1:])
|
2021-01-16 06:36:44 +00:00
|
|
|
case "Find":
|
2021-02-07 05:51:51 +00:00
|
|
|
return p.parseFindOperation(methodNameTokens[1:])
|
2021-01-27 12:15:25 +00:00
|
|
|
case "Update":
|
2021-02-07 05:51:51 +00:00
|
|
|
return p.parseUpdateOperation(methodNameTokens[1:])
|
2021-01-26 13:23:52 +00:00
|
|
|
case "Delete":
|
2021-02-07 05:51:51 +00:00
|
|
|
return p.parseDeleteOperation(methodNameTokens[1:])
|
2021-02-06 11:05:47 +00:00
|
|
|
case "Count":
|
2021-02-07 05:51:51 +00:00
|
|
|
return p.parseCountOperation(methodNameTokens[1:])
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
2021-02-14 04:48:09 +00:00
|
|
|
return nil, NewUnknownOperationError(methodNameTokens[0])
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
func (p interfaceMethodParser) parseInsertOperation(tokens []string) (Operation, error) {
|
2021-02-01 14:39:20 +00:00
|
|
|
mode, err := p.extractInsertReturns(p.Method.Returns)
|
|
|
|
if err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-02-01 14:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := p.validateContextParam(); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-02-01 14:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pointerType := code.PointerType{ContainedType: p.StructModel.ReferencedType()}
|
|
|
|
if mode == QueryModeOne && p.Method.Params[1].Type != pointerType {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, InvalidParamError
|
2021-02-01 14:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
arrayType := code.ArrayType{ContainedType: pointerType}
|
|
|
|
if mode == QueryModeMany && p.Method.Params[1].Type != arrayType {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, InvalidParamError
|
2021-02-01 14:39:20 +00:00
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
return InsertOperation{
|
2021-02-06 11:05:47 +00:00
|
|
|
Mode: mode,
|
2021-02-07 05:51:51 +00:00
|
|
|
}, nil
|
2021-02-01 14:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p interfaceMethodParser) extractInsertReturns(returns []code.Type) (QueryMode, error) {
|
|
|
|
if len(returns) != 2 {
|
|
|
|
return "", UnsupportedReturnError
|
|
|
|
}
|
|
|
|
|
|
|
|
if returns[1] != code.SimpleType("error") {
|
|
|
|
return "", UnsupportedReturnError
|
|
|
|
}
|
|
|
|
|
|
|
|
interfaceType, ok := returns[0].(code.InterfaceType)
|
|
|
|
if ok {
|
|
|
|
if len(interfaceType.Methods) != 0 {
|
|
|
|
return "", UnsupportedReturnError
|
|
|
|
}
|
|
|
|
return QueryModeOne, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
arrayType, ok := returns[0].(code.ArrayType)
|
|
|
|
if ok {
|
|
|
|
interfaceType, ok := arrayType.ContainedType.(code.InterfaceType)
|
|
|
|
if !ok || len(interfaceType.Methods) != 0 {
|
|
|
|
return "", UnsupportedReturnError
|
|
|
|
}
|
|
|
|
return QueryModeMany, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return "", UnsupportedReturnError
|
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
func (p interfaceMethodParser) parseFindOperation(tokens []string) (Operation, error) {
|
2021-02-06 11:05:47 +00:00
|
|
|
mode, err := p.extractModelOrSliceReturns(p.Method.Returns)
|
2021-01-16 06:36:44 +00:00
|
|
|
if err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 03:27:00 +00:00
|
|
|
queryTokens, sortTokens := p.splitQueryAndSortTokens(tokens)
|
|
|
|
|
2021-03-03 14:01:32 +00:00
|
|
|
querySpec, err := p.parseQuery(queryTokens, 1)
|
2021-02-26 03:27:00 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
sorts, err := p.parseSort(sortTokens)
|
2021-01-16 06:36:44 +00:00
|
|
|
if err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-01-27 12:15:25 +00:00
|
|
|
if err := p.validateContextParam(); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-27 12:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := p.validateQueryFromParams(p.Method.Params[1:], querySpec); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
return FindOperation{
|
2021-02-06 11:05:47 +00:00
|
|
|
Mode: mode,
|
|
|
|
Query: querySpec,
|
2021-02-26 03:27:00 +00:00
|
|
|
Sorts: sorts,
|
2021-02-07 05:51:51 +00:00
|
|
|
}, nil
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 03:27:00 +00:00
|
|
|
func (p interfaceMethodParser) parseSort(rawTokens []string) ([]Sort, error) {
|
|
|
|
if len(rawTokens) == 0 {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2021-03-03 14:01:32 +00:00
|
|
|
sortTokens, ok := splitByAnd(rawTokens[2:])
|
|
|
|
if !ok {
|
|
|
|
return nil, NewInvalidSortError(rawTokens)
|
|
|
|
}
|
2021-02-26 03:27:00 +00:00
|
|
|
|
|
|
|
var sorts []Sort
|
|
|
|
for _, token := range sortTokens {
|
2021-03-03 14:01:32 +00:00
|
|
|
sort, err := p.parseSortToken(token)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2021-02-26 03:27:00 +00:00
|
|
|
}
|
2021-03-03 14:01:32 +00:00
|
|
|
sorts = append(sorts, sort)
|
2021-02-26 03:27:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return sorts, nil
|
|
|
|
}
|
|
|
|
|
2021-03-03 14:01:32 +00:00
|
|
|
func (p interfaceMethodParser) parseSortToken(t []string) (Sort, error) {
|
2021-02-26 03:27:00 +00:00
|
|
|
if len(t) > 1 && t[len(t)-1] == "Asc" {
|
2021-03-03 14:01:32 +00:00
|
|
|
return p.createSort(t[:len(t)-1], OrderingAscending)
|
2021-02-26 03:27:00 +00:00
|
|
|
}
|
|
|
|
if len(t) > 1 && t[len(t)-1] == "Desc" {
|
2021-03-03 14:01:32 +00:00
|
|
|
return p.createSort(t[:len(t)-1], OrderingDescending)
|
|
|
|
}
|
|
|
|
return p.createSort(t, OrderingAscending)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p interfaceMethodParser) createSort(t []string, ordering Ordering) (Sort, error) {
|
|
|
|
fields, ok := p.fieldResolver.ResolveStructField(p.StructModel, t)
|
|
|
|
if !ok {
|
|
|
|
return Sort{}, NewStructFieldNotFoundError(t)
|
2021-02-26 03:27:00 +00:00
|
|
|
}
|
2021-03-03 14:01:32 +00:00
|
|
|
|
|
|
|
return Sort{
|
|
|
|
FieldReference: fields,
|
|
|
|
Ordering: ordering,
|
|
|
|
}, nil
|
2021-02-26 03:27:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p interfaceMethodParser) splitQueryAndSortTokens(tokens []string) ([]string, []string) {
|
|
|
|
var queryTokens []string
|
|
|
|
var sortTokens []string
|
|
|
|
|
|
|
|
for i, token := range tokens {
|
|
|
|
if len(tokens) > i && token == "Order" && tokens[i+1] == "By" {
|
|
|
|
sortTokens = tokens[i:]
|
|
|
|
break
|
|
|
|
} else {
|
|
|
|
queryTokens = append(queryTokens, token)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return queryTokens, sortTokens
|
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
func (p interfaceMethodParser) extractModelOrSliceReturns(returns []code.Type) (QueryMode, error) {
|
2021-01-16 06:36:44 +00:00
|
|
|
if len(returns) != 2 {
|
2021-01-21 11:56:30 +00:00
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if returns[1] != code.SimpleType("error") {
|
2021-01-21 11:56:30 +00:00
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pointerType, ok := returns[0].(code.PointerType)
|
|
|
|
if ok {
|
|
|
|
simpleType := pointerType.ContainedType
|
|
|
|
if simpleType == code.SimpleType(p.StructModel.Name) {
|
|
|
|
return QueryModeOne, nil
|
|
|
|
}
|
2021-01-21 11:56:30 +00:00
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
arrayType, ok := returns[0].(code.ArrayType)
|
|
|
|
if ok {
|
|
|
|
pointerType, ok := arrayType.ContainedType.(code.PointerType)
|
|
|
|
if ok {
|
|
|
|
simpleType := pointerType.ContainedType
|
|
|
|
if simpleType == code.SimpleType(p.StructModel.Name) {
|
|
|
|
return QueryModeMany, nil
|
|
|
|
}
|
2021-01-21 11:56:30 +00:00
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-21 11:56:30 +00:00
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-03 14:01:32 +00:00
|
|
|
func splitByAnd(tokens []string) ([][]string, bool) {
|
|
|
|
var updateFieldTokens [][]string
|
|
|
|
var aggregatedToken []string
|
|
|
|
|
|
|
|
for _, token := range tokens {
|
|
|
|
if token != "And" {
|
|
|
|
aggregatedToken = append(aggregatedToken, token)
|
|
|
|
} else if len(aggregatedToken) == 0 {
|
|
|
|
return nil, false
|
|
|
|
} else {
|
|
|
|
updateFieldTokens = append(updateFieldTokens, aggregatedToken)
|
|
|
|
aggregatedToken = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(aggregatedToken) == 0 {
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
updateFieldTokens = append(updateFieldTokens, aggregatedToken)
|
|
|
|
|
|
|
|
return updateFieldTokens, true
|
2021-01-27 12:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-02-24 12:02:57 +00:00
|
|
|
func (p interfaceMethodParser) splitUpdateAndQueryTokens(tokens []string) ([]string, []string) {
|
|
|
|
var updateTokens []string
|
2021-02-07 05:51:51 +00:00
|
|
|
var queryTokens []string
|
|
|
|
|
|
|
|
for i, token := range tokens {
|
|
|
|
if token == "By" || token == "All" {
|
|
|
|
queryTokens = tokens[i:]
|
|
|
|
break
|
|
|
|
} else {
|
2021-02-24 12:02:57 +00:00
|
|
|
updateTokens = append(updateTokens, token)
|
2021-02-07 05:51:51 +00:00
|
|
|
}
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-24 12:02:57 +00:00
|
|
|
return updateTokens, queryTokens
|
2021-02-07 05:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p interfaceMethodParser) parseDeleteOperation(tokens []string) (Operation, error) {
|
2021-02-06 11:05:47 +00:00
|
|
|
mode, err := p.extractIntOrBoolReturns(p.Method.Returns)
|
2021-01-26 13:23:52 +00:00
|
|
|
if err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-03-03 14:01:32 +00:00
|
|
|
querySpec, err := p.parseQuery(tokens, 1)
|
2021-01-26 13:23:52 +00:00
|
|
|
if err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-01-27 12:15:25 +00:00
|
|
|
if err := p.validateContextParam(); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-27 12:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := p.validateQueryFromParams(p.Method.Params[1:], querySpec); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
return DeleteOperation{
|
2021-02-06 11:05:47 +00:00
|
|
|
Mode: mode,
|
|
|
|
Query: querySpec,
|
2021-02-07 05:51:51 +00:00
|
|
|
}, nil
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
func (p interfaceMethodParser) parseCountOperation(tokens []string) (Operation, error) {
|
2021-02-06 11:05:47 +00:00
|
|
|
if err := p.validateCountReturns(p.Method.Returns); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-03-03 14:01:32 +00:00
|
|
|
querySpec, err := p.parseQuery(tokens, 1)
|
2021-02-06 11:05:47 +00:00
|
|
|
if err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
if err := p.validateContextParam(); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-02-06 11:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := p.validateQueryFromParams(p.Method.Params[1:], querySpec); err != nil {
|
2021-02-07 05:51:51 +00:00
|
|
|
return nil, err
|
2021-02-06 11:05:47 +00:00
|
|
|
}
|
|
|
|
|
2021-02-07 05:51:51 +00:00
|
|
|
return CountOperation{
|
2021-02-06 11:05:47 +00:00
|
|
|
Query: querySpec,
|
2021-02-07 05:51:51 +00:00
|
|
|
}, nil
|
2021-01-26 13:23:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
func (p interfaceMethodParser) validateCountReturns(returns []code.Type) error {
|
|
|
|
if len(returns) != 2 {
|
|
|
|
return UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
if returns[0] != code.SimpleType("int") {
|
|
|
|
return UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
if returns[1] != code.SimpleType("error") {
|
|
|
|
return UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
2021-02-06 11:05:47 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p interfaceMethodParser) extractIntOrBoolReturns(returns []code.Type) (QueryMode, error) {
|
|
|
|
if len(returns) != 2 {
|
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
if returns[1] != code.SimpleType("error") {
|
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
2021-01-19 12:26:26 +00:00
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
simpleType, ok := returns[0].(code.SimpleType)
|
|
|
|
if ok {
|
|
|
|
if simpleType == code.SimpleType("bool") {
|
|
|
|
return QueryModeOne, nil
|
|
|
|
}
|
|
|
|
if simpleType == code.SimpleType("int") {
|
|
|
|
return QueryModeMany, nil
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-06 11:05:47 +00:00
|
|
|
return "", UnsupportedReturnError
|
2021-01-16 06:36:44 +00:00
|
|
|
}
|
2021-01-21 11:56:30 +00:00
|
|
|
|
2021-01-27 12:15:25 +00:00
|
|
|
func (p interfaceMethodParser) validateContextParam() error {
|
2021-01-21 11:56:30 +00:00
|
|
|
contextType := code.ExternalType{PackageAlias: "context", Name: "Context"}
|
|
|
|
if len(p.Method.Params) == 0 || p.Method.Params[0].Type != contextType {
|
|
|
|
return ContextParamRequiredError
|
|
|
|
}
|
2021-01-27 12:15:25 +00:00
|
|
|
return nil
|
|
|
|
}
|
2021-01-21 11:56:30 +00:00
|
|
|
|
2021-01-27 12:15:25 +00:00
|
|
|
func (p interfaceMethodParser) validateQueryFromParams(params []code.Param, querySpec QuerySpec) error {
|
|
|
|
if querySpec.NumberOfArguments() != len(params) {
|
2021-01-21 11:56:30 +00:00
|
|
|
return InvalidParamError
|
|
|
|
}
|
|
|
|
|
2021-01-27 12:15:25 +00:00
|
|
|
var currentParamIndex int
|
2021-01-21 11:56:30 +00:00
|
|
|
for _, predicate := range querySpec.Predicates {
|
2021-02-23 12:10:25 +00:00
|
|
|
if (predicate.Comparator == ComparatorTrue || predicate.Comparator == ComparatorFalse) &&
|
2021-03-03 14:01:32 +00:00
|
|
|
predicate.FieldReference.ReferencedField().Type != code.SimpleType("bool") {
|
|
|
|
return NewIncompatibleComparatorError(predicate.Comparator,
|
|
|
|
predicate.FieldReference.ReferencedField())
|
2021-02-23 12:10:25 +00:00
|
|
|
}
|
|
|
|
|
2021-01-24 08:31:21 +00:00
|
|
|
for i := 0; i < predicate.Comparator.NumberOfArguments(); i++ {
|
2021-05-03 07:12:58 +00:00
|
|
|
requiredType := predicate.Comparator.ArgumentTypeFromFieldType(predicate.FieldReference.ReferencedField().Type)
|
|
|
|
|
|
|
|
if params[currentParamIndex].Type != requiredType {
|
|
|
|
return NewArgumentTypeNotMatchedError(predicate.FieldReference.ReferencingCode(), requiredType,
|
|
|
|
params[currentParamIndex].Type)
|
2021-01-24 08:31:21 +00:00
|
|
|
}
|
|
|
|
currentParamIndex++
|
2021-01-21 11:56:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2021-03-03 14:01:32 +00:00
|
|
|
|
|
|
|
func (p interfaceMethodParser) parseQuery(queryTokens []string, paramIndex int) (QuerySpec, error) {
|
|
|
|
queryParser := queryParser{
|
|
|
|
fieldResolver: p.fieldResolver,
|
|
|
|
StructModel: p.StructModel,
|
|
|
|
}
|
|
|
|
return queryParser.parseQuery(queryTokens, paramIndex)
|
|
|
|
}
|