diff --git a/cmd/hasura-ndc-go/command/internal/connector.go b/cmd/hasura-ndc-go/command/internal/connector.go index 6d85ee9..d6370a2 100644 --- a/cmd/hasura-ndc-go/command/internal/connector.go +++ b/cmd/hasura-ndc-go/command/internal/connector.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/hasura/ndc-sdk-go/schema" + "github.com/iancoleman/strcase" "github.com/rs/zerolog/log" ) @@ -24,6 +25,7 @@ type ConnectorGenerationArguments struct { PackageTypes string `help:"The name of types package where the State struct is in"` Directories []string `help:"Folders contain NDC operation functions" short:"d"` Trace string `help:"Enable tracing and write to target file path."` + Style string `help:"The naming style for functions and procedures. Accept: camel-case, snake-case" enum:"camel-case,snake-case" default:"camel-case"` } type connectorTypeBuilder struct { @@ -500,10 +502,10 @@ func (j %s) ScalarName() string { sb.imports["slices"] = "" sb.builder.WriteString("const (\n") - pascalName := ToPascalCase(scalar.Name) + pascalName := strcase.ToCamel(scalar.Name) enumConstants := make([]string, len(scalarRep.OneOf)) for i, enum := range scalarRep.OneOf { - enumConst := fmt.Sprintf("%s%s", pascalName, ToPascalCase(enum)) + enumConst := fmt.Sprintf("%s%s", pascalName, strcase.ToCamel(enum)) enumConstants[i] = enumConst sb.builder.WriteString(fmt.Sprintf(" %s %s = \"%s\"\n", enumConst, scalar.Name, enum)) } diff --git a/cmd/hasura-ndc-go/command/internal/connector_test.go b/cmd/hasura-ndc-go/command/internal/connector_test.go index b0d21be..b45a12d 100644 --- a/cmd/hasura-ndc-go/command/internal/connector_test.go +++ b/cmd/hasura-ndc-go/command/internal/connector_test.go @@ -31,6 +31,7 @@ func TestConnectorGeneration(t *testing.T) { Directories []string ModuleName string PackageTypes string + NamingStyle string errorMsg string }{ { @@ -75,6 +76,13 @@ func TestConnectorGeneration(t *testing.T) { Directories: []string{"connector/functions"}, errorMsg: "the `types` package where the State struct is in must be placed in root or connector directory", }, + { + Name: "snake_case", + BasePath: "./testdata/snake_case", + ModuleName: "github.com/hasura/ndc-codegen-test-snake-case", + Directories: []string{"functions"}, + NamingStyle: string(StyleSnakeCase), + }, } rootDir, err := os.Getwd() @@ -94,6 +102,7 @@ func TestConnectorGeneration(t *testing.T) { ConnectorDir: tc.ConnectorDir, PackageTypes: tc.PackageTypes, Directories: tc.Directories, + Style: tc.NamingStyle, }, tc.ModuleName) if tc.errorMsg != "" { assert.ErrorContains(t, err, tc.errorMsg) diff --git a/cmd/hasura-ndc-go/command/internal/constant.go b/cmd/hasura-ndc-go/command/internal/constant.go index cbf51bf..c9884c5 100644 --- a/cmd/hasura-ndc-go/command/internal/constant.go +++ b/cmd/hasura-ndc-go/command/internal/constant.go @@ -7,6 +7,7 @@ import ( "text/template" "github.com/hasura/ndc-sdk-go/schema" + "github.com/iancoleman/strcase" ) const ( @@ -25,6 +26,11 @@ func init() { if err != nil { panic(fmt.Errorf("failed to parse connector template: %s", err)) } + + strcase.ConfigureAcronym("API", "Api") + strcase.ConfigureAcronym("REST", "Rest") + strcase.ConfigureAcronym("HTTP", "Http") + strcase.ConfigureAcronym("SQL", "sql") } type ScalarName string diff --git a/cmd/hasura-ndc-go/command/internal/schema.go b/cmd/hasura-ndc-go/command/internal/schema.go index 1280a40..99dfd28 100644 --- a/cmd/hasura-ndc-go/command/internal/schema.go +++ b/cmd/hasura-ndc-go/command/internal/schema.go @@ -17,6 +17,7 @@ import ( "github.com/fatih/structtag" "github.com/hasura/ndc-sdk-go/schema" + "github.com/iancoleman/strcase" "github.com/rs/zerolog/log" "golang.org/x/tools/go/packages" ) @@ -213,6 +214,7 @@ type SchemaParser struct { rawSchema *RawConnectorSchema packages []*packages.Package packageIndex int + namingStyle OperationNamingStyle } // GetCurrentPackage gets the current evaluating package @@ -231,6 +233,14 @@ func (sp SchemaParser) FindPackageByPath(input string) *packages.Package { } func parseRawConnectorSchemaFromGoCode(ctx context.Context, moduleName string, filePath string, args *ConnectorGenerationArguments) (*RawConnectorSchema, error) { + var err error + namingStyle := StyleCamelCase + if args.Style != "" { + namingStyle, err = ParseOperationNamingStyle(args.Style) + if err != nil { + return nil, err + } + } rawSchema := NewRawConnectorSchema() pkgTypes, err := evalPackageTypesLocation(args.PackageTypes, moduleName, filePath, args.ConnectorDir) @@ -312,6 +322,7 @@ func parseRawConnectorSchemaFromGoCode(ctx context.Context, moduleName string, f packages: packageList, packageIndex: i, rawSchema: rawSchema, + namingStyle: namingStyle, } err = sp.parseRawConnectorSchema(packageList[i].Types) @@ -846,6 +857,16 @@ func (sp *SchemaParser) parseTypeInfoFromComments(typeName string, packagePath s return typeInfo, nil } +// format operation name with style +func (sp SchemaParser) formatOperationName(name string) string { + switch sp.namingStyle { + case StyleSnakeCase: + return strcase.ToSnake(name) + default: + return strcase.ToLowerCamel(name) + } +} + func (sp *SchemaParser) parseOperationInfo(fn *types.Func) *OperationInfo { functionName := fn.Name() result := OperationInfo{ @@ -878,7 +899,7 @@ func (sp *SchemaParser) parseOperationInfo(fn *types.Func) *OperationInfo { if matchesLen > 3 && strings.TrimSpace(matches[3]) != "" { result.Name = strings.TrimSpace(matches[3]) } else { - result.Name = ToCamelCase(functionName) + result.Name = sp.formatOperationName(functionName) } } else { descriptions = append(descriptions, text) @@ -895,7 +916,7 @@ func (sp *SchemaParser) parseOperationInfo(fn *types.Func) *OperationInfo { return nil } result.Kind = OperationKind(operationNameResults[1]) - result.Name = ToCamelCase(operationNameResults[2]) + result.Name = sp.formatOperationName(operationNameResults[2]) } desc := strings.TrimSpace(strings.Join(descriptions, " ")) diff --git a/cmd/hasura-ndc-go/command/internal/stringer.go b/cmd/hasura-ndc-go/command/internal/stringer.go deleted file mode 100644 index 3a44364..0000000 --- a/cmd/hasura-ndc-go/command/internal/stringer.go +++ /dev/null @@ -1,33 +0,0 @@ -package internal - -import ( - "regexp" - "strings" -) - -var nonAlphaDigitRegex = regexp.MustCompile(`[^\w]+`) - -// ToCamelCase convert a string to camelCase -func ToCamelCase(input string) string { - pascalCase := ToPascalCase(input) - if pascalCase == "" { - return pascalCase - } - return strings.ToLower(pascalCase[:1]) + pascalCase[1:] -} - -// ToPascalCase convert a string to PascalCase -func ToPascalCase(input string) string { - if input == "" { - return input - } - input = nonAlphaDigitRegex.ReplaceAllString(input, "_") - parts := strings.Split(input, "_") - for i := range parts { - if parts[i] == "" { - continue - } - parts[i] = strings.ToUpper(parts[i][:1]) + parts[i][1:] - } - return strings.Join(parts, "") -} diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/connector.go.tmpl b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/connector.go.tmpl new file mode 100644 index 0000000..1ebb31e --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/connector.go.tmpl @@ -0,0 +1,384 @@ +// Code generated by github.com/hasura/ndc-sdk-go/codegen, DO NOT EDIT. +package main + +import ( + "context" + _ "embed" + "fmt" + "log/slog" + + "encoding/json" +"github.com/hasura/ndc-codegen-test-snake-case/functions" +"github.com/hasura/ndc-codegen-test-snake-case/types" + "github.com/hasura/ndc-sdk-go/connector" + "github.com/hasura/ndc-sdk-go/schema" + "github.com/hasura/ndc-sdk-go/utils" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/trace" +) + +//go:embed schema.generated.json +var rawSchema []byte +var schemaResponse *schema.RawSchemaResponse + +func init() { + var err error + schemaResponse, err = schema.NewRawSchemaResponse(rawSchema) + if err != nil { + panic(err) + } +} + +// GetSchema gets the connector's schema. +func (c *Connector) GetSchema(ctx context.Context, configuration *types.Configuration, _ *types.State) (schema.SchemaResponseMarshaler, error) { + return schemaResponse, nil +} + +// Query executes a query. +func (c *Connector) Query(ctx context.Context, configuration *types.Configuration, state *types.State, request *schema.QueryRequest) (schema.QueryResponse, error) { + valueField, err := utils.EvalFunctionSelectionFieldValue(request) + if err != nil { + return nil, schema.UnprocessableContentError(err.Error(), nil) + } + + span := trace.SpanFromContext(ctx) + requestVars := request.Variables + varsLength := len(requestVars) + if varsLength == 0 { + requestVars = []schema.QueryRequestVariablesElem{make(schema.QueryRequestVariablesElem)} + varsLength = 1 + } + + rowSets := make([]schema.RowSet, varsLength) + for i, requestVar := range requestVars { + childSpan := span + childContext := ctx + if varsLength > 1 { + childContext, childSpan = state.Tracer.Start(ctx, fmt.Sprintf("execute_function_%d", i)) + defer childSpan.End() + } + + result, err := execQuery(childContext, state, request, valueField, requestVar, childSpan) + if err != nil { + if varsLength > 1 { + childSpan.SetStatus(codes.Error, err.Error()) + } + return nil, err + } + rowSets[i] = schema.RowSet{ + Aggregates: schema.RowSetAggregates{}, + Rows: []map[string]any{ + { + "__value": result, + }, + }, + } + if varsLength > 1 { + childSpan.End() + } + } + + return rowSets, nil +} + +// Mutation executes a mutation. +func (c *Connector) Mutation(ctx context.Context, configuration *types.Configuration, state *types.State, request *schema.MutationRequest) (*schema.MutationResponse, error) { + operationLen := len(request.Operations) + operationResults := make([]schema.MutationOperationResults, operationLen) + span := trace.SpanFromContext(ctx) + + for i, operation := range request.Operations { + childSpan := span + childContext := ctx + if operationLen > 1 { + childContext, childSpan = state.Tracer.Start(ctx, fmt.Sprintf("execute_operation_%d", i)) + defer childSpan.End() + } + childSpan.SetAttributes( + attribute.String("operation.type", string(operation.Type)), + attribute.String("operation.name", string(operation.Name)), + ) + + switch operation.Type { + case schema.MutationOperationProcedure: + result, err := execProcedure(childContext, state, &operation, childSpan) + if err != nil { + if operationLen > 1 { + childSpan.SetStatus(codes.Error, err.Error()) + } + return nil, err + } + operationResults[i] = result + if operationLen > 1 { + childSpan.End() + } + default: + return nil, schema.UnprocessableContentError(fmt.Sprintf("invalid operation type: %s", operation.Type), nil) + } + } + + return &schema.MutationResponse{ + OperationResults: operationResults, + }, nil +} + +func execQuery(ctx context.Context, state *types.State, request *schema.QueryRequest, queryFields schema.NestedField, variables map[string]any, span trace.Span) (any, error) { + logger := connector.GetLogger(ctx) + connector_addSpanEvent(span, logger, "validate_request", map[string]any{ + "variables": variables, + }) + switch request.Collection { + case "get_bool": + if len(queryFields) > 0 { + return nil, schema.UnprocessableContentError("cannot evaluate selection fields for scalar", nil) + } + return functions.FunctionGetBool(ctx, state) + case "get_types": + selection, err := queryFields.AsObject() + if err != nil { + return nil, schema.UnprocessableContentError("the selection field type must be object", map[string]any{ + "cause": err.Error(), + }) + } + rawArgs, err := utils.ResolveArgumentVariables(request.Arguments, variables) + if err != nil { + return nil, schema.UnprocessableContentError("failed to resolve argument variables", map[string]any{ + "cause": err.Error(), + }) + } + + connector_addSpanEvent(span, logger, "resolve_arguments", map[string]any{ + "raw_arguments": rawArgs, + }) + + var args functions.GetTypesArguments + if err = args.FromValue(rawArgs); err != nil { + return nil, schema.UnprocessableContentError("failed to resolve arguments", map[string]any{ + "cause": err.Error(), + }) + } + + connector_addSpanEvent(span, logger, "execute_function", map[string]any{ + "arguments": args, + }) + rawResult, err := functions.FunctionGetTypes(ctx, state, &args) + if err != nil { + return nil, err + } + + if rawResult == nil { + return nil, nil + } + + connector_addSpanEvent(span, logger, "evaluate_response_selection", map[string]any{ + "raw_result": rawResult, + }) + result, err := utils.EvalNestedColumnObject(selection, rawResult) + if err != nil { + return nil, err + } + return result, nil + case "hello": + selection, err := queryFields.AsObject() + if err != nil { + return nil, schema.UnprocessableContentError("the selection field type must be object", map[string]any{ + "cause": err.Error(), + }) + } + rawResult, err := functions.FunctionHello(ctx, state) + if err != nil { + return nil, err + } + + if rawResult == nil { + return nil, nil + } + + connector_addSpanEvent(span, logger, "evaluate_response_selection", map[string]any{ + "raw_result": rawResult, + }) + result, err := utils.EvalNestedColumnObject(selection, rawResult) + if err != nil { + return nil, err + } + return result, nil + case "get_articles": + selection, err := queryFields.AsArray() + if err != nil { + return nil, schema.UnprocessableContentError("the selection field type must be array", map[string]any{ + "cause": err.Error(), + }) + } + rawArgs, err := utils.ResolveArgumentVariables(request.Arguments, variables) + if err != nil { + return nil, schema.UnprocessableContentError("failed to resolve argument variables", map[string]any{ + "cause": err.Error(), + }) + } + + connector_addSpanEvent(span, logger, "resolve_arguments", map[string]any{ + "raw_arguments": rawArgs, + }) + + var args functions.GetArticlesArguments + if err = args.FromValue(rawArgs); err != nil { + return nil, schema.UnprocessableContentError("failed to resolve arguments", map[string]any{ + "cause": err.Error(), + }) + } + + connector_addSpanEvent(span, logger, "execute_function", map[string]any{ + "arguments": args, + }) + rawResult, err := functions.GetArticles(ctx, state, &args) + if err != nil { + return nil, err + } + + if rawResult == nil { + return nil, schema.UnprocessableContentError("expected not null result", nil) + } + + connector_addSpanEvent(span, logger, "evaluate_response_selection", map[string]any{ + "raw_result": rawResult, + }) + result, err := utils.EvalNestedColumnArrayIntoSlice(selection, rawResult) + if err != nil { + return nil, err + } + return result, nil + + default: + return nil, schema.UnprocessableContentError(fmt.Sprintf("unsupported query: %s", request.Collection), nil) + } +} + +func execProcedure(ctx context.Context, state *types.State, operation *schema.MutationOperation, span trace.Span) (schema.MutationOperationResults, error) { + logger := connector.GetLogger(ctx) + connector_addSpanEvent(span, logger, "validate_request", map[string]any{ + "operations_name": operation.Name, + }) + switch operation.Name { + case "create_article": + selection, err := operation.Fields.AsObject() + if err != nil { + return nil, schema.UnprocessableContentError("the selection field type must be object", map[string]any{ + "cause": err.Error(), + }) + } + var args functions.CreateArticleArguments + if err := json.Unmarshal(operation.Arguments, &args); err != nil { + return nil, schema.UnprocessableContentError("failed to decode arguments", map[string]any{ + "cause": err.Error(), + }) + } + span.AddEvent("execute_procedure") + rawResult, err := functions.CreateArticle(ctx, state, &args) + + if err != nil { + return nil, err + } + + if rawResult == nil { + return nil, nil + } + connector_addSpanEvent(span, logger, "evaluate_response_selection", map[string]any{ + "raw_result": rawResult, + }) + result, err := utils.EvalNestedColumnObject(selection, rawResult) + + if err != nil { + return nil, err + } + return schema.NewProcedureResult(result).Encode(), nil + case "increase": + if len(operation.Fields) > 0 { + return nil, schema.UnprocessableContentError("cannot evaluate selection fields for scalar", nil) + } + span.AddEvent("execute_procedure") + var err error + result, err := functions.Increase(ctx, state) + if err != nil { + return nil, err + } + return schema.NewProcedureResult(result).Encode(), nil + case "create_author": + selection, err := operation.Fields.AsObject() + if err != nil { + return nil, schema.UnprocessableContentError("the selection field type must be object", map[string]any{ + "cause": err.Error(), + }) + } + var args functions.CreateAuthorArguments + if err := json.Unmarshal(operation.Arguments, &args); err != nil { + return nil, schema.UnprocessableContentError("failed to decode arguments", map[string]any{ + "cause": err.Error(), + }) + } + span.AddEvent("execute_procedure") + rawResult, err := functions.ProcedureCreateAuthor(ctx, state, &args) + + if err != nil { + return nil, err + } + + if rawResult == nil { + return nil, nil + } + connector_addSpanEvent(span, logger, "evaluate_response_selection", map[string]any{ + "raw_result": rawResult, + }) + result, err := utils.EvalNestedColumnObject(selection, rawResult) + + if err != nil { + return nil, err + } + return schema.NewProcedureResult(result).Encode(), nil + case "create_authors": + selection, err := operation.Fields.AsArray() + if err != nil { + return nil, schema.UnprocessableContentError("the selection field type must be array", map[string]any{ + "cause": err.Error(), + }) + } + var args functions.CreateAuthorsArguments + if err := json.Unmarshal(operation.Arguments, &args); err != nil { + return nil, schema.UnprocessableContentError("failed to decode arguments", map[string]any{ + "cause": err.Error(), + }) + } + span.AddEvent("execute_procedure") + rawResult, err := functions.ProcedureCreateAuthors(ctx, state, &args) + + if err != nil { + return nil, err + } + + if rawResult == nil { + return nil, schema.UnprocessableContentError("expected not null result", nil) + } + connector_addSpanEvent(span, logger, "evaluate_response_selection", map[string]any{ + "raw_result": rawResult, + }) + result, err := utils.EvalNestedColumnArrayIntoSlice(selection, rawResult) + + if err != nil { + return nil, err + } + return schema.NewProcedureResult(result).Encode(), nil + + default: + return nil, schema.UnprocessableContentError(fmt.Sprintf("unsupported procedure operation: %s", operation.Name), nil) + } +} + +func connector_addSpanEvent(span trace.Span, logger *slog.Logger, name string, data map[string]any, options ...trace.EventOption) { + logger.Debug(name, slog.Any("data", data)) + attrs := utils.DebugJSONAttributes(data, connector_isDebug(logger)) + span.AddEvent(name, append(options, trace.WithAttributes(attrs...))...) +} + +func connector_isDebug(logger *slog.Logger) bool { + return logger.Enabled(context.TODO(), slog.LevelDebug) +} \ No newline at end of file diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/functions.go.tmpl b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/functions.go.tmpl new file mode 100644 index 0000000..eb6594f --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/functions.go.tmpl @@ -0,0 +1,895 @@ +// Code generated by github.com/hasura/ndc-sdk-go/codegen, DO NOT EDIT. +package functions +import ( + "encoding/json" + "errors" + "github.com/google/uuid" + "github.com/hasura/ndc-sdk-go/scalar" + "github.com/hasura/ndc-sdk-go/utils" + "slices" + "time" +) +var functions_Decoder = utils.NewDecoder() + +// FromValue decodes values from map +func (j *GetTypesArguments) FromValue(input map[string]any) error { + var err error + err = functions_Decoder.DecodeObjectValue(&j.ArrayBigInt, input, "ArrayBigInt") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.ArrayBigIntPtr, input, "ArrayBigIntPtr") + if err != nil { + return err + } + j.ArrayBool, err = utils.GetBooleanSlice(input, "ArrayBool") + if err != nil { + return err + } + j.ArrayBoolPtr, err = utils.GetBooleanPtrSlice(input, "ArrayBoolPtr") + if err != nil { + return err + } + j.ArrayFloat32, err = utils.GetFloatSlice[float32](input, "ArrayFloat32") + if err != nil { + return err + } + j.ArrayFloat32Ptr, err = utils.GetFloatPtrSlice[float32](input, "ArrayFloat32Ptr") + if err != nil { + return err + } + j.ArrayFloat64, err = utils.GetFloatSlice[float64](input, "ArrayFloat64") + if err != nil { + return err + } + j.ArrayFloat64Ptr, err = utils.GetFloatPtrSlice[float64](input, "ArrayFloat64Ptr") + if err != nil { + return err + } + j.ArrayInt, err = utils.GetIntSlice[int](input, "ArrayInt") + if err != nil { + return err + } + j.ArrayInt16, err = utils.GetIntSlice[int16](input, "ArrayInt16") + if err != nil { + return err + } + j.ArrayInt16Ptr, err = utils.GetIntPtrSlice[int16](input, "ArrayInt16Ptr") + if err != nil { + return err + } + j.ArrayInt32, err = utils.GetIntSlice[int32](input, "ArrayInt32") + if err != nil { + return err + } + j.ArrayInt32Ptr, err = utils.GetIntPtrSlice[int32](input, "ArrayInt32Ptr") + if err != nil { + return err + } + j.ArrayInt64, err = utils.GetIntSlice[int64](input, "ArrayInt64") + if err != nil { + return err + } + j.ArrayInt64Ptr, err = utils.GetIntPtrSlice[int64](input, "ArrayInt64Ptr") + if err != nil { + return err + } + j.ArrayInt8, err = utils.GetIntSlice[int8](input, "ArrayInt8") + if err != nil { + return err + } + j.ArrayInt8Ptr, err = utils.GetIntPtrSlice[int8](input, "ArrayInt8Ptr") + if err != nil { + return err + } + j.ArrayIntPtr, err = utils.GetIntPtrSlice[int](input, "ArrayIntPtr") + if err != nil { + return err + } + j.ArrayJSON, err = utils.GetArbitraryJSONSlice(input, "ArrayJSON") + if err != nil { + return err + } + j.ArrayJSONPtr, err = utils.GetArbitraryJSONPtrSlice(input, "ArrayJSONPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.ArrayMap, input, "ArrayMap") + if err != nil { + return err + } + j.ArrayMapPtr = new([]map[string]any) + err = functions_Decoder.DecodeNullableObjectValue(j.ArrayMapPtr, input, "ArrayMapPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.ArrayObject, input, "ArrayObject") + if err != nil { + return err + } + j.ArrayObjectPtr = new([]struct{Content string "json:\"content\""}) + err = functions_Decoder.DecodeNullableObjectValue(j.ArrayObjectPtr, input, "ArrayObjectPtr") + if err != nil { + return err + } + j.ArrayRawJSON, err = utils.GetRawJSONSlice(input, "ArrayRawJSON") + if err != nil { + return err + } + j.ArrayRawJSONPtr, err = utils.GetRawJSONPtrSlice(input, "ArrayRawJSONPtr") + if err != nil { + return err + } + j.ArrayString, err = utils.GetStringSlice(input, "ArrayString") + if err != nil { + return err + } + j.ArrayStringPtr, err = utils.GetStringPtrSlice(input, "ArrayStringPtr") + if err != nil { + return err + } + j.ArrayTime, err = utils.GetDateTimeSlice(input, "ArrayTime") + if err != nil { + return err + } + j.ArrayTimePtr, err = utils.GetDateTimePtrSlice(input, "ArrayTimePtr") + if err != nil { + return err + } + j.ArrayUUID, err = utils.GetUUIDSlice(input, "ArrayUUID") + if err != nil { + return err + } + j.ArrayUUIDPtr, err = utils.GetUUIDPtrSlice(input, "ArrayUUIDPtr") + if err != nil { + return err + } + j.ArrayUint, err = utils.GetUintSlice[uint](input, "ArrayUint") + if err != nil { + return err + } + j.ArrayUint16, err = utils.GetUintSlice[uint16](input, "ArrayUint16") + if err != nil { + return err + } + j.ArrayUint16Ptr, err = utils.GetUintPtrSlice[uint16](input, "ArrayUint16Ptr") + if err != nil { + return err + } + j.ArrayUint32, err = utils.GetUintSlice[uint32](input, "ArrayUint32") + if err != nil { + return err + } + j.ArrayUint32Ptr, err = utils.GetUintPtrSlice[uint32](input, "ArrayUint32Ptr") + if err != nil { + return err + } + j.ArrayUint64, err = utils.GetUintSlice[uint64](input, "ArrayUint64") + if err != nil { + return err + } + j.ArrayUint64Ptr, err = utils.GetUintPtrSlice[uint64](input, "ArrayUint64Ptr") + if err != nil { + return err + } + j.ArrayUint8, err = utils.GetUintSlice[uint8](input, "ArrayUint8") + if err != nil { + return err + } + j.ArrayUint8Ptr, err = utils.GetUintPtrSlice[uint8](input, "ArrayUint8Ptr") + if err != nil { + return err + } + j.ArrayUintPtr, err = utils.GetUintPtrSlice[uint](input, "ArrayUintPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.BigInt, input, "BigInt") + if err != nil { + return err + } + j.BigIntPtr = new(scalar.BigInt) + err = functions_Decoder.DecodeNullableObjectValue(j.BigIntPtr, input, "BigIntPtr") + if err != nil { + return err + } + j.Bool, err = utils.GetBoolean(input, "Bool") + if err != nil { + return err + } + j.BoolPtr, err = utils.GetNullableBoolean(input, "BoolPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.Bytes, input, "Bytes") + if err != nil { + return err + } + j.BytesPtr = new(scalar.Bytes) + err = functions_Decoder.DecodeNullableObjectValue(j.BytesPtr, input, "BytesPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.CustomScalar, input, "CustomScalar") + if err != nil { + return err + } + j.CustomScalarPtr = new(CommentText) + err = functions_Decoder.DecodeNullableObjectValue(j.CustomScalarPtr, input, "CustomScalarPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.Enum, input, "Enum") + if err != nil { + return err + } + j.EnumPtr = new(SomeEnum) + err = functions_Decoder.DecodeNullableObjectValue(j.EnumPtr, input, "EnumPtr") + if err != nil { + return err + } + j.Float32, err = utils.GetFloat[float32](input, "Float32") + if err != nil { + return err + } + j.Float32Ptr, err = utils.GetNullableFloat[float32](input, "Float32Ptr") + if err != nil { + return err + } + j.Float64, err = utils.GetFloat[float64](input, "Float64") + if err != nil { + return err + } + j.Float64Ptr, err = utils.GetNullableFloat[float64](input, "Float64Ptr") + if err != nil { + return err + } + j.Int, err = utils.GetInt[int](input, "Int") + if err != nil { + return err + } + j.Int16, err = utils.GetInt[int16](input, "Int16") + if err != nil { + return err + } + j.Int16Ptr, err = utils.GetNullableInt[int16](input, "Int16Ptr") + if err != nil { + return err + } + j.Int32, err = utils.GetInt[int32](input, "Int32") + if err != nil { + return err + } + j.Int32Ptr, err = utils.GetNullableInt[int32](input, "Int32Ptr") + if err != nil { + return err + } + j.Int64, err = utils.GetInt[int64](input, "Int64") + if err != nil { + return err + } + j.Int64Ptr, err = utils.GetNullableInt[int64](input, "Int64Ptr") + if err != nil { + return err + } + j.Int8, err = utils.GetInt[int8](input, "Int8") + if err != nil { + return err + } + j.Int8Ptr, err = utils.GetNullableInt[int8](input, "Int8Ptr") + if err != nil { + return err + } + j.IntPtr, err = utils.GetNullableInt[int](input, "IntPtr") + if err != nil { + return err + } + j.JSON, err = utils.GetArbitraryJSON(input, "JSON") + if err != nil { + return err + } + j.JSONPtr, err = utils.GetNullableArbitraryJSON(input, "JSONPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.Map, input, "Map") + if err != nil { + return err + } + j.MapPtr = new(map[string]any) + err = functions_Decoder.DecodeNullableObjectValue(j.MapPtr, input, "MapPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.NamedArray, input, "NamedArray") + if err != nil { + return err + } + j.NamedArrayPtr = new([]Author) + err = functions_Decoder.DecodeNullableObjectValue(j.NamedArrayPtr, input, "NamedArrayPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.NamedObject, input, "NamedObject") + if err != nil { + return err + } + j.NamedObjectPtr = new(Author) + err = functions_Decoder.DecodeNullableObjectValue(j.NamedObjectPtr, input, "NamedObjectPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.Object, input, "Object") + if err != nil { + return err + } + j.ObjectPtr = new(struct{Long int; Lat int}) + err = functions_Decoder.DecodeNullableObjectValue(j.ObjectPtr, input, "ObjectPtr") + if err != nil { + return err + } + j.PtrArrayBigInt = new([]scalar.BigInt) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayBigInt, input, "PtrArrayBigInt") + if err != nil { + return err + } + j.PtrArrayBigIntPtr = new([]*scalar.BigInt) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayBigIntPtr, input, "PtrArrayBigIntPtr") + if err != nil { + return err + } + j.PtrArrayBool = new([]bool) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayBool, input, "PtrArrayBool") + if err != nil { + return err + } + j.PtrArrayBoolPtr, err = utils.GetNullableBooleanPtrSlice(input, "PtrArrayBoolPtr") + if err != nil { + return err + } + j.PtrArrayFloat32 = new([]float32) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayFloat32, input, "PtrArrayFloat32") + if err != nil { + return err + } + j.PtrArrayFloat32Ptr, err = utils.GetNullableFloatPtrSlice[float32](input, "PtrArrayFloat32Ptr") + if err != nil { + return err + } + j.PtrArrayFloat64 = new([]float64) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayFloat64, input, "PtrArrayFloat64") + if err != nil { + return err + } + j.PtrArrayFloat64Ptr, err = utils.GetNullableFloatPtrSlice[float64](input, "PtrArrayFloat64Ptr") + if err != nil { + return err + } + j.PtrArrayInt = new([]int) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayInt, input, "PtrArrayInt") + if err != nil { + return err + } + j.PtrArrayInt16 = new([]int16) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayInt16, input, "PtrArrayInt16") + if err != nil { + return err + } + j.PtrArrayInt16Ptr, err = utils.GetNullableIntPtrSlice[int16](input, "PtrArrayInt16Ptr") + if err != nil { + return err + } + j.PtrArrayInt32 = new([]int32) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayInt32, input, "PtrArrayInt32") + if err != nil { + return err + } + j.PtrArrayInt32Ptr, err = utils.GetNullableIntPtrSlice[int32](input, "PtrArrayInt32Ptr") + if err != nil { + return err + } + j.PtrArrayInt64 = new([]int64) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayInt64, input, "PtrArrayInt64") + if err != nil { + return err + } + j.PtrArrayInt64Ptr, err = utils.GetNullableIntPtrSlice[int64](input, "PtrArrayInt64Ptr") + if err != nil { + return err + } + j.PtrArrayInt8 = new([]int8) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayInt8, input, "PtrArrayInt8") + if err != nil { + return err + } + j.PtrArrayInt8Ptr, err = utils.GetNullableIntPtrSlice[int8](input, "PtrArrayInt8Ptr") + if err != nil { + return err + } + j.PtrArrayIntPtr, err = utils.GetNullableIntPtrSlice[int](input, "PtrArrayIntPtr") + if err != nil { + return err + } + j.PtrArrayJSON = new([]any) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayJSON, input, "PtrArrayJSON") + if err != nil { + return err + } + j.PtrArrayJSONPtr, err = utils.GetNullableArbitraryJSONPtrSlice(input, "PtrArrayJSONPtr") + if err != nil { + return err + } + j.PtrArrayRawJSON = new([]json.RawMessage) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayRawJSON, input, "PtrArrayRawJSON") + if err != nil { + return err + } + j.PtrArrayRawJSONPtr, err = utils.GetNullableRawJSONPtrSlice(input, "PtrArrayRawJSONPtr") + if err != nil { + return err + } + j.PtrArrayString = new([]string) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayString, input, "PtrArrayString") + if err != nil { + return err + } + j.PtrArrayStringPtr, err = utils.GetNullableStringPtrSlice(input, "PtrArrayStringPtr") + if err != nil { + return err + } + j.PtrArrayTime = new([]time.Time) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayTime, input, "PtrArrayTime") + if err != nil { + return err + } + j.PtrArrayTimePtr, err = utils.GetNullableDateTimePtrSlice(input, "PtrArrayTimePtr") + if err != nil { + return err + } + j.PtrArrayUUID = new([]uuid.UUID) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayUUID, input, "PtrArrayUUID") + if err != nil { + return err + } + j.PtrArrayUUIDPtr, err = utils.GetNullableUUIDPtrSlice(input, "PtrArrayUUIDPtr") + if err != nil { + return err + } + j.PtrArrayUint = new([]uint) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayUint, input, "PtrArrayUint") + if err != nil { + return err + } + j.PtrArrayUint16 = new([]uint16) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayUint16, input, "PtrArrayUint16") + if err != nil { + return err + } + j.PtrArrayUint16Ptr, err = utils.GetNullableUintPtrSlice[uint16](input, "PtrArrayUint16Ptr") + if err != nil { + return err + } + j.PtrArrayUint32 = new([]uint32) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayUint32, input, "PtrArrayUint32") + if err != nil { + return err + } + j.PtrArrayUint32Ptr, err = utils.GetNullableUintPtrSlice[uint32](input, "PtrArrayUint32Ptr") + if err != nil { + return err + } + j.PtrArrayUint64 = new([]uint64) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayUint64, input, "PtrArrayUint64") + if err != nil { + return err + } + j.PtrArrayUint64Ptr, err = utils.GetNullableUintPtrSlice[uint64](input, "PtrArrayUint64Ptr") + if err != nil { + return err + } + j.PtrArrayUint8 = new([]uint8) + err = functions_Decoder.DecodeNullableObjectValue(j.PtrArrayUint8, input, "PtrArrayUint8") + if err != nil { + return err + } + j.PtrArrayUint8Ptr, err = utils.GetNullableUintPtrSlice[uint8](input, "PtrArrayUint8Ptr") + if err != nil { + return err + } + j.PtrArrayUintPtr, err = utils.GetNullableUintPtrSlice[uint](input, "PtrArrayUintPtr") + if err != nil { + return err + } + j.RawJSON, err = utils.GetRawJSON(input, "RawJSON") + if err != nil { + return err + } + j.RawJSONPtr, err = utils.GetNullableRawJSON(input, "RawJSONPtr") + if err != nil { + return err + } + j.String, err = utils.GetString(input, "String") + if err != nil { + return err + } + j.StringPtr, err = utils.GetNullableString(input, "StringPtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.Text, input, "Text") + if err != nil { + return err + } + j.TextPtr = new(Text) + err = functions_Decoder.DecodeNullableObjectValue(j.TextPtr, input, "TextPtr") + if err != nil { + return err + } + j.Time, err = utils.GetDateTime(input, "Time") + if err != nil { + return err + } + j.TimePtr, err = utils.GetNullableDateTime(input, "TimePtr") + if err != nil { + return err + } + err = functions_Decoder.DecodeObjectValue(&j.URL, input, "URL") + if err != nil { + return err + } + j.UUID, err = utils.GetUUID(input, "UUID") + if err != nil { + return err + } + j.UUIDArray, err = utils.GetUUIDSlice(input, "UUIDArray") + if err != nil { + return err + } + j.UUIDPtr, err = utils.GetNullableUUID(input, "UUIDPtr") + if err != nil { + return err + } + j.Uint, err = utils.GetUint[uint](input, "Uint") + if err != nil { + return err + } + j.Uint16, err = utils.GetUint[uint16](input, "Uint16") + if err != nil { + return err + } + j.Uint16Ptr, err = utils.GetNullableUint[uint16](input, "Uint16Ptr") + if err != nil { + return err + } + j.Uint32, err = utils.GetUint[uint32](input, "Uint32") + if err != nil { + return err + } + j.Uint32Ptr, err = utils.GetNullableUint[uint32](input, "Uint32Ptr") + if err != nil { + return err + } + j.Uint64, err = utils.GetUint[uint64](input, "Uint64") + if err != nil { + return err + } + j.Uint64Ptr, err = utils.GetNullableUint[uint64](input, "Uint64Ptr") + if err != nil { + return err + } + j.Uint8, err = utils.GetUint[uint8](input, "Uint8") + if err != nil { + return err + } + j.Uint8Ptr, err = utils.GetNullableUint[uint8](input, "Uint8Ptr") + if err != nil { + return err + } + j.UintPtr, err = utils.GetNullableUint[uint](input, "UintPtr") + if err != nil { + return err + } + return nil +} +// FromValue decodes values from map +func (j *GetArticlesArguments) FromValue(input map[string]any) error { + var err error + j.Limit, err = utils.GetFloat[float64](input, "Limit") + if err != nil { + return err + } + return nil +} +// ToMap encodes the struct to a value map +func (j Author) ToMap() map[string]any { + r := make(map[string]any) + r["created_at"] = j.CreatedAt + r["id"] = j.ID + + return r +} +// ToMap encodes the struct to a value map +func (j CreateArticleResult) ToMap() map[string]any { + r := make(map[string]any) + j_Authors := make([]any, len(j.Authors)) + for i, j_Authors_v := range j.Authors { + j_Authors[i] = j_Authors_v + } + r["authors"] = j_Authors + r["id"] = j.ID + + return r +} +// ToMap encodes the struct to a value map +func (j CreateAuthorResult) ToMap() map[string]any { + r := make(map[string]any) + r["created_at"] = j.CreatedAt + r["id"] = j.ID + r["name"] = j.Name + + return r +} +// ToMap encodes the struct to a value map +func (j GetArticlesResult) ToMap() map[string]any { + r := make(map[string]any) + r["id"] = j.ID + r["Name"] = j.Name + + return r +} +// ToMap encodes the struct to a value map +func (j GetTypesArguments) ToMap() map[string]any { + r := make(map[string]any) + r["ArrayBigInt"] = j.ArrayBigInt + r["ArrayBigIntPtr"] = j.ArrayBigIntPtr + r["ArrayBool"] = j.ArrayBool + r["ArrayBoolPtr"] = j.ArrayBoolPtr + r["ArrayFloat32"] = j.ArrayFloat32 + r["ArrayFloat32Ptr"] = j.ArrayFloat32Ptr + r["ArrayFloat64"] = j.ArrayFloat64 + r["ArrayFloat64Ptr"] = j.ArrayFloat64Ptr + r["ArrayInt"] = j.ArrayInt + r["ArrayInt16"] = j.ArrayInt16 + r["ArrayInt16Ptr"] = j.ArrayInt16Ptr + r["ArrayInt32"] = j.ArrayInt32 + r["ArrayInt32Ptr"] = j.ArrayInt32Ptr + r["ArrayInt64"] = j.ArrayInt64 + r["ArrayInt64Ptr"] = j.ArrayInt64Ptr + r["ArrayInt8"] = j.ArrayInt8 + r["ArrayInt8Ptr"] = j.ArrayInt8Ptr + r["ArrayIntPtr"] = j.ArrayIntPtr + r["ArrayJSON"] = j.ArrayJSON + r["ArrayJSONPtr"] = j.ArrayJSONPtr + r["ArrayMap"] = j.ArrayMap + r["ArrayMapPtr"] = j.ArrayMapPtr + j_ArrayObject := make([]any, len(j.ArrayObject)) + for i, j_ArrayObject_v := range j.ArrayObject { + j_ArrayObject_v_obj := make(map[string]any) + j_ArrayObject_v_obj["content"] = j_ArrayObject_v.Content + j_ArrayObject[i] = j_ArrayObject_v_obj + } + r["ArrayObject"] = j_ArrayObject + if j.ArrayObjectPtr != nil { + j_ArrayObjectPtr := make([]any, len((*j.ArrayObjectPtr))) + for i, j_ArrayObjectPtr_v := range (*j.ArrayObjectPtr) { + j_ArrayObjectPtr_v_obj := make(map[string]any) + j_ArrayObjectPtr_v_obj["content"] = j_ArrayObjectPtr_v.Content + j_ArrayObjectPtr[i] = j_ArrayObjectPtr_v_obj + } + r["ArrayObjectPtr"] = j_ArrayObjectPtr + } + r["ArrayRawJSON"] = j.ArrayRawJSON + r["ArrayRawJSONPtr"] = j.ArrayRawJSONPtr + r["ArrayString"] = j.ArrayString + r["ArrayStringPtr"] = j.ArrayStringPtr + r["ArrayTime"] = j.ArrayTime + r["ArrayTimePtr"] = j.ArrayTimePtr + r["ArrayUUID"] = j.ArrayUUID + r["ArrayUUIDPtr"] = j.ArrayUUIDPtr + r["ArrayUint"] = j.ArrayUint + r["ArrayUint16"] = j.ArrayUint16 + r["ArrayUint16Ptr"] = j.ArrayUint16Ptr + r["ArrayUint32"] = j.ArrayUint32 + r["ArrayUint32Ptr"] = j.ArrayUint32Ptr + r["ArrayUint64"] = j.ArrayUint64 + r["ArrayUint64Ptr"] = j.ArrayUint64Ptr + r["ArrayUint8"] = j.ArrayUint8 + r["ArrayUint8Ptr"] = j.ArrayUint8Ptr + r["ArrayUintPtr"] = j.ArrayUintPtr + r["BigInt"] = j.BigInt + r["BigIntPtr"] = j.BigIntPtr + r["Bool"] = j.Bool + r["BoolPtr"] = j.BoolPtr + r["Bytes"] = j.Bytes + r["BytesPtr"] = j.BytesPtr + r["CustomScalar"] = j.CustomScalar + r["CustomScalarPtr"] = j.CustomScalarPtr + r["Enum"] = j.Enum + r["EnumPtr"] = j.EnumPtr + r["Float32"] = j.Float32 + r["Float32Ptr"] = j.Float32Ptr + r["Float64"] = j.Float64 + r["Float64Ptr"] = j.Float64Ptr + r["Int"] = j.Int + r["Int16"] = j.Int16 + r["Int16Ptr"] = j.Int16Ptr + r["Int32"] = j.Int32 + r["Int32Ptr"] = j.Int32Ptr + r["Int64"] = j.Int64 + r["Int64Ptr"] = j.Int64Ptr + r["Int8"] = j.Int8 + r["Int8Ptr"] = j.Int8Ptr + r["IntPtr"] = j.IntPtr + r["JSON"] = j.JSON + r["JSONPtr"] = j.JSONPtr + r["Map"] = j.Map + r["MapPtr"] = j.MapPtr + j_NamedArray := make([]any, len(j.NamedArray)) + for i, j_NamedArray_v := range j.NamedArray { + j_NamedArray[i] = j_NamedArray_v + } + r["NamedArray"] = j_NamedArray + if j.NamedArrayPtr != nil { + j_NamedArrayPtr := make([]any, len((*j.NamedArrayPtr))) + for i, j_NamedArrayPtr_v := range (*j.NamedArrayPtr) { + j_NamedArrayPtr[i] = j_NamedArrayPtr_v + } + r["NamedArrayPtr"] = j_NamedArrayPtr + } + r["NamedObject"] = j.NamedObject + if j.NamedObjectPtr != nil { + r["NamedObjectPtr"] = (*j.NamedObjectPtr) + } + j_Object_obj := make(map[string]any) + j_Object_obj["created_at"] = j.Object.CreatedAt + j_Object_obj["id"] = j.Object.ID + r["Object"] = j_Object_obj + if j.ObjectPtr != nil { + j_ObjectPtr__obj := make(map[string]any) + j_ObjectPtr__obj["Lat"] = (*j.ObjectPtr).Lat + j_ObjectPtr__obj["Long"] = (*j.ObjectPtr).Long + r["ObjectPtr"] = j_ObjectPtr__obj + } + r["PtrArrayBigInt"] = j.PtrArrayBigInt + r["PtrArrayBigIntPtr"] = j.PtrArrayBigIntPtr + r["PtrArrayBool"] = j.PtrArrayBool + r["PtrArrayBoolPtr"] = j.PtrArrayBoolPtr + r["PtrArrayFloat32"] = j.PtrArrayFloat32 + r["PtrArrayFloat32Ptr"] = j.PtrArrayFloat32Ptr + r["PtrArrayFloat64"] = j.PtrArrayFloat64 + r["PtrArrayFloat64Ptr"] = j.PtrArrayFloat64Ptr + r["PtrArrayInt"] = j.PtrArrayInt + r["PtrArrayInt16"] = j.PtrArrayInt16 + r["PtrArrayInt16Ptr"] = j.PtrArrayInt16Ptr + r["PtrArrayInt32"] = j.PtrArrayInt32 + r["PtrArrayInt32Ptr"] = j.PtrArrayInt32Ptr + r["PtrArrayInt64"] = j.PtrArrayInt64 + r["PtrArrayInt64Ptr"] = j.PtrArrayInt64Ptr + r["PtrArrayInt8"] = j.PtrArrayInt8 + r["PtrArrayInt8Ptr"] = j.PtrArrayInt8Ptr + r["PtrArrayIntPtr"] = j.PtrArrayIntPtr + r["PtrArrayJSON"] = j.PtrArrayJSON + r["PtrArrayJSONPtr"] = j.PtrArrayJSONPtr + r["PtrArrayRawJSON"] = j.PtrArrayRawJSON + r["PtrArrayRawJSONPtr"] = j.PtrArrayRawJSONPtr + r["PtrArrayString"] = j.PtrArrayString + r["PtrArrayStringPtr"] = j.PtrArrayStringPtr + r["PtrArrayTime"] = j.PtrArrayTime + r["PtrArrayTimePtr"] = j.PtrArrayTimePtr + r["PtrArrayUUID"] = j.PtrArrayUUID + r["PtrArrayUUIDPtr"] = j.PtrArrayUUIDPtr + r["PtrArrayUint"] = j.PtrArrayUint + r["PtrArrayUint16"] = j.PtrArrayUint16 + r["PtrArrayUint16Ptr"] = j.PtrArrayUint16Ptr + r["PtrArrayUint32"] = j.PtrArrayUint32 + r["PtrArrayUint32Ptr"] = j.PtrArrayUint32Ptr + r["PtrArrayUint64"] = j.PtrArrayUint64 + r["PtrArrayUint64Ptr"] = j.PtrArrayUint64Ptr + r["PtrArrayUint8"] = j.PtrArrayUint8 + r["PtrArrayUint8Ptr"] = j.PtrArrayUint8Ptr + r["PtrArrayUintPtr"] = j.PtrArrayUintPtr + r["RawJSON"] = j.RawJSON + r["RawJSONPtr"] = j.RawJSONPtr + r["String"] = j.String + r["StringPtr"] = j.StringPtr + r["Text"] = j.Text + r["TextPtr"] = j.TextPtr + r["Time"] = j.Time + r["TimePtr"] = j.TimePtr + r["URL"] = j.URL + r["UUID"] = j.UUID + r["UUIDArray"] = j.UUIDArray + r["UUIDPtr"] = j.UUIDPtr + r["Uint"] = j.Uint + r["Uint16"] = j.Uint16 + r["Uint16Ptr"] = j.Uint16Ptr + r["Uint32"] = j.Uint32 + r["Uint32Ptr"] = j.Uint32Ptr + r["Uint64"] = j.Uint64 + r["Uint64Ptr"] = j.Uint64Ptr + r["Uint8"] = j.Uint8 + r["Uint8Ptr"] = j.Uint8Ptr + r["UintPtr"] = j.UintPtr + + return r +} +// ToMap encodes the struct to a value map +func (j HelloResult) ToMap() map[string]any { + r := make(map[string]any) + r["error"] = j.Error + r["foo"] = j.Foo + r["id"] = j.ID + r["num"] = j.Num + r["text"] = j.Text + + return r +} +// ScalarName get the schema name of the scalar +func (j CommentText) ScalarName() string { + return "CommentString" +} + +// ScalarName get the schema name of the scalar +func (j ScalarFoo) ScalarName() string { + return "Foo" +} + +// ScalarName get the schema name of the scalar +func (j SomeEnum) ScalarName() string { + return "SomeEnum" +} +const ( + SomeEnumFoo SomeEnum = "foo" + SomeEnumBar SomeEnum = "bar" +) + +var enumValues_SomeEnum = []SomeEnum{SomeEnumFoo, SomeEnumBar} + +// ParseSomeEnum parses a SomeEnum enum from string +func ParseSomeEnum(input string) (SomeEnum, error) { + result := SomeEnum(input) + if !slices.Contains(enumValues_SomeEnum, result) { + return SomeEnum(""), errors.New("failed to parse SomeEnum, expect one of SomeEnumFoo, SomeEnumBar") + } + + return result, nil +} + +// IsValid checks if the value is invalid +func (j SomeEnum) IsValid() bool { + return slices.Contains(enumValues_SomeEnum, j) +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SomeEnum) UnmarshalJSON(b []byte) error { + var rawValue string + if err := json.Unmarshal(b, &rawValue); err != nil { + return err + } + + value, err := ParseSomeEnum(rawValue) + if err != nil { + return err + } + + *j = value + return nil +} + +// FromValue decodes the scalar from an unknown value +func (s *SomeEnum) FromValue(value any) error { + valueStr, err := utils.DecodeNullableString(value) + if err != nil { + return err + } + if valueStr == nil { + return nil + } + result, err := ParseSomeEnum(*valueStr) + if err != nil { + return err + } + + *s = result + return nil +} diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/schema.json b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/schema.json new file mode 100644 index 0000000..99fca05 --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/expected/schema.json @@ -0,0 +1,3201 @@ +{ + "collections": [], + "functions": [ + { + "arguments": {}, + "description": "return an scalar boolean", + "name": "get_bool", + "result_type": { + "name": "Boolean", + "type": "named" + } + }, + { + "arguments": { + "ArrayBigInt": { + "type": { + "element_type": { + "name": "BigInt", + "type": "named" + }, + "type": "array" + } + }, + "ArrayBigIntPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "BigInt", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayBool": { + "type": { + "element_type": { + "name": "Boolean", + "type": "named" + }, + "type": "array" + } + }, + "ArrayBoolPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Boolean", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayFloat32": { + "type": { + "element_type": { + "name": "Float32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayFloat32Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayFloat64": { + "type": { + "element_type": { + "name": "Float64", + "type": "named" + }, + "type": "array" + } + }, + "ArrayFloat64Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float64", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt16": { + "type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt16Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt32": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt32Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt64": { + "type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt64Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt8": { + "type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt8Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayIntPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayJSON": { + "type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + }, + "ArrayJSONPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayMap": { + "type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + }, + "ArrayMapPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + } + }, + "ArrayObject": { + "type": { + "element_type": { + "name": "GetTypesArgumentsArrayObject", + "type": "named" + }, + "type": "array" + } + }, + "ArrayObjectPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "GetTypesArgumentsArrayObjectPtr", + "type": "named" + }, + "type": "array" + } + } + }, + "ArrayRawJSON": { + "type": { + "element_type": { + "name": "RawJSON", + "type": "named" + }, + "type": "array" + } + }, + "ArrayRawJSONPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "RawJSON", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayString": { + "type": { + "element_type": { + "name": "String", + "type": "named" + }, + "type": "array" + } + }, + "ArrayStringPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayTime": { + "type": { + "element_type": { + "name": "TimestampTZ", + "type": "named" + }, + "type": "array" + } + }, + "ArrayTimePtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUUID": { + "type": { + "element_type": { + "name": "UUID", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUUIDPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "UUID", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint16": { + "type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint16Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint32": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint32Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint64": { + "type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint64Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint8": { + "type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint8Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUintPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "BigInt": { + "type": { + "name": "BigInt", + "type": "named" + } + }, + "BigIntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "BigInt", + "type": "named" + } + } + }, + "Bool": { + "type": { + "name": "Boolean", + "type": "named" + } + }, + "BoolPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Boolean", + "type": "named" + } + } + }, + "Bytes": { + "type": { + "name": "Bytes", + "type": "named" + } + }, + "BytesPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Bytes", + "type": "named" + } + } + }, + "CustomScalar": { + "type": { + "name": "CommentString", + "type": "named" + } + }, + "CustomScalarPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "CommentString", + "type": "named" + } + } + }, + "Enum": { + "type": { + "name": "SomeEnum", + "type": "named" + } + }, + "EnumPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "SomeEnum", + "type": "named" + } + } + }, + "Float32": { + "type": { + "name": "Float32", + "type": "named" + } + }, + "Float32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Float32", + "type": "named" + } + } + }, + "Float64": { + "type": { + "name": "Float64", + "type": "named" + } + }, + "Float64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Float64", + "type": "named" + } + } + }, + "Int": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Int16": { + "type": { + "name": "Int16", + "type": "named" + } + }, + "Int16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + } + }, + "Int32": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Int32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + }, + "Int64": { + "type": { + "name": "Int64", + "type": "named" + } + }, + "Int64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + } + }, + "Int8": { + "type": { + "name": "Int8", + "type": "named" + } + }, + "Int8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + } + }, + "IntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + }, + "JSON": { + "type": { + "name": "JSON", + "type": "named" + } + }, + "JSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + } + }, + "Map": { + "type": { + "name": "JSON", + "type": "named" + } + }, + "MapPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + } + }, + "NamedArray": { + "type": { + "element_type": { + "name": "Author", + "type": "named" + }, + "type": "array" + } + }, + "NamedArrayPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Author", + "type": "named" + }, + "type": "array" + } + } + }, + "NamedObject": { + "type": { + "name": "Author", + "type": "named" + } + }, + "NamedObjectPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Author", + "type": "named" + } + } + }, + "Object": { + "type": { + "name": "GetTypesArgumentsObject", + "type": "named" + } + }, + "ObjectPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "GetTypesArgumentsObjectPtr", + "type": "named" + } + } + }, + "PtrArrayBigInt": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "BigInt", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayBigIntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "BigInt", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayBool": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Boolean", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayBoolPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Boolean", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayFloat32": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Float32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayFloat32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayFloat64": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Float64", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayFloat64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float64", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt16": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt32": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt64": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt8": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayIntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayJSON": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayJSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayRawJSON": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "RawJSON", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayRawJSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "RawJSON", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayString": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "String", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayStringPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayTime": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "TimestampTZ", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayTimePtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUUID": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "UUID", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUUIDPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "UUID", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint16": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint32": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint64": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint8": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUintPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "RawJSON": { + "type": { + "name": "RawJSON", + "type": "named" + } + }, + "RawJSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "RawJSON", + "type": "named" + } + } + }, + "String": { + "type": { + "name": "String", + "type": "named" + } + }, + "StringPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + } + }, + "Text": { + "type": { + "name": "String", + "type": "named" + } + }, + "TextPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + } + }, + "Time": { + "type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "TimePtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "TimestampTZ", + "type": "named" + } + } + }, + "URL": { + "type": { + "name": "URL", + "type": "named" + } + }, + "UUID": { + "type": { + "name": "UUID", + "type": "named" + } + }, + "UUIDArray": { + "type": { + "element_type": { + "name": "UUID", + "type": "named" + }, + "type": "array" + } + }, + "UUIDPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "UUID", + "type": "named" + } + } + }, + "Uint": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Uint16": { + "type": { + "name": "Int16", + "type": "named" + } + }, + "Uint16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + } + }, + "Uint32": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Uint32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + }, + "Uint64": { + "type": { + "name": "Int64", + "type": "named" + } + }, + "Uint64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + } + }, + "Uint8": { + "type": { + "name": "Int8", + "type": "named" + } + }, + "Uint8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + } + }, + "UintPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + } + }, + "name": "get_types", + "result_type": { + "type": "nullable", + "underlying_type": { + "name": "GetTypesArguments", + "type": "named" + } + } + }, + { + "arguments": {}, + "description": "sends a hello message", + "name": "hello", + "result_type": { + "type": "nullable", + "underlying_type": { + "name": "HelloResult", + "type": "named" + } + } + }, + { + "arguments": { + "Limit": { + "type": { + "name": "Float64", + "type": "named" + } + } + }, + "description": "GetArticles", + "name": "get_articles", + "result_type": { + "element_type": { + "name": "GetArticlesResult", + "type": "named" + }, + "type": "array" + } + } + ], + "object_types": { + "Author": { + "fields": { + "created_at": { + "type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "id": { + "type": { + "name": "String", + "type": "named" + } + } + } + }, + "CreateArticleArgumentsAuthor": { + "fields": { + "created_at": { + "type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "id": { + "type": { + "name": "UUID", + "type": "named" + } + } + } + }, + "CreateArticleResult": { + "fields": { + "authors": { + "type": { + "element_type": { + "name": "Author", + "type": "named" + }, + "type": "array" + } + }, + "id": { + "type": { + "name": "Int32", + "type": "named" + } + } + } + }, + "CreateAuthorResult": { + "fields": { + "created_at": { + "type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "id": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "name": { + "type": { + "name": "String", + "type": "named" + } + } + } + }, + "GetArticlesResult": { + "fields": { + "Name": { + "type": { + "name": "String", + "type": "named" + } + }, + "id": { + "type": { + "name": "String", + "type": "named" + } + } + } + }, + "GetTypesArguments": { + "fields": { + "ArrayBigInt": { + "type": { + "element_type": { + "name": "BigInt", + "type": "named" + }, + "type": "array" + } + }, + "ArrayBigIntPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "BigInt", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayBool": { + "type": { + "element_type": { + "name": "Boolean", + "type": "named" + }, + "type": "array" + } + }, + "ArrayBoolPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Boolean", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayFloat32": { + "type": { + "element_type": { + "name": "Float32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayFloat32Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayFloat64": { + "type": { + "element_type": { + "name": "Float64", + "type": "named" + }, + "type": "array" + } + }, + "ArrayFloat64Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float64", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt16": { + "type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt16Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt32": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt32Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt64": { + "type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt64Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayInt8": { + "type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + }, + "ArrayInt8Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayIntPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayJSON": { + "type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + }, + "ArrayJSONPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayMap": { + "type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + }, + "ArrayMapPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + } + }, + "ArrayObject": { + "type": { + "element_type": { + "name": "GetTypesArgumentsArrayObject", + "type": "named" + }, + "type": "array" + } + }, + "ArrayObjectPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "GetTypesArgumentsArrayObjectPtr", + "type": "named" + }, + "type": "array" + } + } + }, + "ArrayRawJSON": { + "type": { + "element_type": { + "name": "RawJSON", + "type": "named" + }, + "type": "array" + } + }, + "ArrayRawJSONPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "RawJSON", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayString": { + "type": { + "element_type": { + "name": "String", + "type": "named" + }, + "type": "array" + } + }, + "ArrayStringPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayTime": { + "type": { + "element_type": { + "name": "TimestampTZ", + "type": "named" + }, + "type": "array" + } + }, + "ArrayTimePtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUUID": { + "type": { + "element_type": { + "name": "UUID", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUUIDPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "UUID", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint16": { + "type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint16Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint32": { + "type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint32Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint64": { + "type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint64Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUint8": { + "type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + }, + "ArrayUint8Ptr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + }, + "ArrayUintPtr": { + "type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + }, + "BigInt": { + "type": { + "name": "BigInt", + "type": "named" + } + }, + "BigIntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "BigInt", + "type": "named" + } + } + }, + "Bool": { + "type": { + "name": "Boolean", + "type": "named" + } + }, + "BoolPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Boolean", + "type": "named" + } + } + }, + "Bytes": { + "type": { + "name": "Bytes", + "type": "named" + } + }, + "BytesPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Bytes", + "type": "named" + } + } + }, + "CustomScalar": { + "type": { + "name": "CommentString", + "type": "named" + } + }, + "CustomScalarPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "CommentString", + "type": "named" + } + } + }, + "Enum": { + "type": { + "name": "SomeEnum", + "type": "named" + } + }, + "EnumPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "SomeEnum", + "type": "named" + } + } + }, + "Float32": { + "type": { + "name": "Float32", + "type": "named" + } + }, + "Float32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Float32", + "type": "named" + } + } + }, + "Float64": { + "type": { + "name": "Float64", + "type": "named" + } + }, + "Float64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Float64", + "type": "named" + } + } + }, + "Int": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Int16": { + "type": { + "name": "Int16", + "type": "named" + } + }, + "Int16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + } + }, + "Int32": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Int32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + }, + "Int64": { + "type": { + "name": "Int64", + "type": "named" + } + }, + "Int64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + } + }, + "Int8": { + "type": { + "name": "Int8", + "type": "named" + } + }, + "Int8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + } + }, + "IntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + }, + "JSON": { + "type": { + "name": "JSON", + "type": "named" + } + }, + "JSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + } + }, + "Map": { + "type": { + "name": "JSON", + "type": "named" + } + }, + "MapPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + } + }, + "NamedArray": { + "type": { + "element_type": { + "name": "Author", + "type": "named" + }, + "type": "array" + } + }, + "NamedArrayPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Author", + "type": "named" + }, + "type": "array" + } + } + }, + "NamedObject": { + "type": { + "name": "Author", + "type": "named" + } + }, + "NamedObjectPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Author", + "type": "named" + } + } + }, + "Object": { + "type": { + "name": "GetTypesArgumentsObject", + "type": "named" + } + }, + "ObjectPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "GetTypesArgumentsObjectPtr", + "type": "named" + } + } + }, + "PtrArrayBigInt": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "BigInt", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayBigIntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "BigInt", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayBool": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Boolean", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayBoolPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Boolean", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayFloat32": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Float32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayFloat32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayFloat64": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Float64", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayFloat64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Float64", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt16": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt32": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt64": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayInt8": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayInt8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayIntPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayJSON": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "JSON", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayJSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayRawJSON": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "RawJSON", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayRawJSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "RawJSON", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayString": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "String", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayStringPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayTime": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "TimestampTZ", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayTimePtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUUID": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "UUID", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUUIDPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "UUID", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint16": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int16", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint32": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int32", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint64": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int64", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUint8": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "name": "Int8", + "type": "named" + }, + "type": "array" + } + } + }, + "PtrArrayUint8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + }, + "type": "array" + } + } + }, + "PtrArrayUintPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "element_type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + }, + "type": "array" + } + } + }, + "RawJSON": { + "type": { + "name": "RawJSON", + "type": "named" + } + }, + "RawJSONPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "RawJSON", + "type": "named" + } + } + }, + "String": { + "type": { + "name": "String", + "type": "named" + } + }, + "StringPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + } + }, + "Text": { + "type": { + "name": "String", + "type": "named" + } + }, + "TextPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "String", + "type": "named" + } + } + }, + "Time": { + "type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "TimePtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "TimestampTZ", + "type": "named" + } + } + }, + "URL": { + "type": { + "name": "URL", + "type": "named" + } + }, + "UUID": { + "type": { + "name": "UUID", + "type": "named" + } + }, + "UUIDArray": { + "type": { + "element_type": { + "name": "UUID", + "type": "named" + }, + "type": "array" + } + }, + "UUIDPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "UUID", + "type": "named" + } + } + }, + "Uint": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Uint16": { + "type": { + "name": "Int16", + "type": "named" + } + }, + "Uint16Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int16", + "type": "named" + } + } + }, + "Uint32": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Uint32Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + }, + "Uint64": { + "type": { + "name": "Int64", + "type": "named" + } + }, + "Uint64Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int64", + "type": "named" + } + } + }, + "Uint8": { + "type": { + "name": "Int8", + "type": "named" + } + }, + "Uint8Ptr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int8", + "type": "named" + } + } + }, + "UintPtr": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "Int32", + "type": "named" + } + } + } + } + }, + "GetTypesArgumentsArrayObject": { + "fields": { + "content": { + "type": { + "name": "String", + "type": "named" + } + } + } + }, + "GetTypesArgumentsArrayObjectPtr": { + "fields": { + "content": { + "type": { + "name": "String", + "type": "named" + } + } + } + }, + "GetTypesArgumentsObject": { + "fields": { + "created_at": { + "type": { + "name": "TimestampTZ", + "type": "named" + } + }, + "id": { + "type": { + "name": "UUID", + "type": "named" + } + } + } + }, + "GetTypesArgumentsObjectPtr": { + "fields": { + "Lat": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "Long": { + "type": { + "name": "Int32", + "type": "named" + } + } + } + }, + "HelloResult": { + "fields": { + "error": { + "type": { + "type": "nullable", + "underlying_type": { + "name": "JSON", + "type": "named" + } + } + }, + "foo": { + "type": { + "name": "Foo", + "type": "named" + } + }, + "id": { + "type": { + "name": "UUID", + "type": "named" + } + }, + "num": { + "type": { + "name": "Int32", + "type": "named" + } + }, + "text": { + "type": { + "name": "String", + "type": "named" + } + } + } + } + }, + "procedures": [ + { + "arguments": { + "author": { + "type": { + "name": "CreateArticleArgumentsAuthor", + "type": "named" + } + } + }, + "description": "CreateArticle", + "name": "create_article", + "result_type": { + "type": "nullable", + "underlying_type": { + "name": "CreateArticleResult", + "type": "named" + } + } + }, + { + "arguments": {}, + "description": "Increase", + "name": "increase", + "result_type": { + "name": "Int32", + "type": "named" + } + }, + { + "arguments": { + "name": { + "type": { + "name": "String", + "type": "named" + } + } + }, + "description": "creates an author", + "name": "create_author", + "result_type": { + "type": "nullable", + "underlying_type": { + "name": "CreateAuthorResult", + "type": "named" + } + } + }, + { + "arguments": { + "names": { + "type": { + "element_type": { + "name": "String", + "type": "named" + }, + "type": "array" + } + } + }, + "description": "creates a list of authors", + "name": "create_authors", + "result_type": { + "element_type": { + "name": "CreateAuthorResult", + "type": "named" + }, + "type": "array" + } + } + ], + "scalar_types": { + "BigInt": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "biginteger" + } + }, + "Boolean": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "boolean" + } + }, + "Bytes": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "bytes" + } + }, + "CommentString": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "json" + } + }, + "Float32": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "float32" + } + }, + "Float64": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "float64" + } + }, + "Foo": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "json" + } + }, + "Int16": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "int16" + } + }, + "Int32": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "int32" + } + }, + "Int64": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "int64" + } + }, + "Int8": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "int8" + } + }, + "JSON": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "json" + } + }, + "RawJSON": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "json" + } + }, + "SomeEnum": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "one_of": ["foo", "bar"], + "type": "enum" + } + }, + "String": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "string" + } + }, + "TimestampTZ": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "timestamptz" + } + }, + "URL": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "string" + } + }, + "UUID": { + "aggregate_functions": {}, + "comparison_operators": {}, + "representation": { + "type": "uuid" + } + } + } +} diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/connector.go b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/connector.go new file mode 100644 index 0000000..a87281a --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/connector.go @@ -0,0 +1,66 @@ +package main + +import ( + "context" + + "github.com/hasura/ndc-codegen-test-snake-case/types" + "github.com/hasura/ndc-sdk-go/connector" + "github.com/hasura/ndc-sdk-go/schema" +) + +var connectorCapabilities = schema.CapabilitiesResponse{ + Version: "0.1.6", + Capabilities: schema.Capabilities{ + Query: schema.QueryCapabilities{ + Variables: schema.LeafCapability{}, + }, + Mutation: schema.MutationCapabilities{}, + }, +} + +// Connector implements the SDK interface of NDC specification +type Connector struct{} + +// ParseConfiguration validates the configuration files provided by the user, returning a validated 'Configuration', +// or throwing an error to prevents Connector startup. +func (c *Connector) ParseConfiguration(ctx context.Context, configurationDir string) (*types.Configuration, error) { + return &types.Configuration{}, nil +} + +// TryInitState initializes the connector's in-memory state. +// +// For example, any connection pools, prepared queries, +// or other managed resources would be allocated here. +// +// In addition, this function should register any +// connector-specific metrics with the metrics registry. +func (c *Connector) TryInitState(ctx context.Context, configuration *types.Configuration, metrics *connector.TelemetryState) (*types.State, error) { + return &types.State{ + TelemetryState: metrics, + }, nil +} + +// HealthCheck checks the health of the connector. +// +// For example, this function should check that the connector +// is able to reach its data source over the network. +// +// Should throw if the check fails, else resolve. +func (c *Connector) HealthCheck(ctx context.Context, configuration *types.Configuration, state *types.State) error { + return nil +} + +// GetCapabilities get the connector's capabilities. +func (c *Connector) GetCapabilities(configuration *types.Configuration) schema.CapabilitiesResponseMarshaler { + return connectorCapabilities +} + +// QueryExplain explains a query by creating an execution plan. +func (c *Connector) QueryExplain(ctx context.Context, configuration *types.Configuration, state *types.State, request *schema.QueryRequest) (*schema.ExplainResponse, error) { + return nil, schema.NotSupportedError("query explain has not been supported yet", nil) +} + +// MutationExplain explains a mutation by creating an execution plan. +func (c *Connector) MutationExplain(ctx context.Context, configuration *types.Configuration, state *types.State, request *schema.MutationRequest) (*schema.ExplainResponse, error) { + return nil, schema.NotSupportedError("mutation explain has not been supported yet", nil) +} diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/functions/comment.go b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/functions/comment.go new file mode 100644 index 0000000..5491ca8 --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/functions/comment.go @@ -0,0 +1,93 @@ +package functions + +import ( + "context" + "encoding/json" + "time" + + "github.com/google/uuid" + "github.com/hasura/ndc-codegen-test-snake-case/types" + "github.com/hasura/ndc-sdk-go/utils" +) + +// CommentText +// @scalar CommentString +type CommentText struct { + comment string +} + +func (c CommentText) MarshalJSON() ([]byte, error) { + return json.Marshal(c.comment) +} + +func (c *CommentText) UnmarshalJSON(b []byte) error { + var s string + if err := json.Unmarshal(b, &s); err != nil { + return err + } + + c.comment = s + + return nil +} + +func (ct *CommentText) FromValue(value any) (err error) { + ct.comment, err = utils.DecodeString(value) + return +} + +// SomeEnum +// @enum foo, bar +type SomeEnum string + +type GetArticlesArguments struct { + Limit float64 +} + +type GetArticlesResult struct { + ID string `json:"id"` + Name Text +} + +// GetArticles +// @function +func GetArticles(ctx context.Context, state *types.State, arguments *GetArticlesArguments) ([]GetArticlesResult, error) { + return []GetArticlesResult{ + { + ID: "1", + Name: "Article 1", + }, + }, nil +} + +type CreateArticleArguments struct { + Author struct { + ID uuid.UUID `json:"id"` + CreatedAt time.Time `json:"created_at"` + } `json:"author"` +} + +type Author struct { + ID string `json:"id"` + CreatedAt time.Time `json:"created_at"` +} + +type CreateArticleResult struct { + ID uint `json:"id"` + Authors []Author `json:"authors"` +} + +// CreateArticle +// @procedure create_article +func CreateArticle(ctx context.Context, state *types.State, arguments *CreateArticleArguments) (*CreateArticleResult, error) { + return &CreateArticleResult{ + ID: 1, + Authors: []Author{}, + }, nil +} + +// Increase +// @procedure +func Increase(ctx context.Context, state *types.State) (int, error) { + return 1, nil +} diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/functions/prefix.go b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/functions/prefix.go new file mode 100644 index 0000000..a07bc74 --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/functions/prefix.go @@ -0,0 +1,243 @@ +package functions + +import ( + "context" + "encoding/json" + "fmt" + "strings" + "time" + + "github.com/google/uuid" + "github.com/hasura/ndc-codegen-test-snake-case/types" + "github.com/hasura/ndc-sdk-go/scalar" +) + +type Text string + +// A foo scalar +type ScalarFoo struct { + bar string +} + +// FromValue decodes the scalar from an unknown value +func (s *ScalarFoo) FromValue(value any) error { + s.bar = fmt.Sprint(value) + return nil +} + +// A hello result +type HelloResult struct { + ID uuid.UUID `json:"id"` + Num int `json:"num"` + Text Text `json:"text"` + Foo ScalarFoo `json:"foo"` + Error error `json:"error"` +} + +// FunctionHello sends a hello message +func FunctionHello(ctx context.Context, state *types.State) (*HelloResult, error) { + return &HelloResult{ + ID: uuid.New(), + Num: 1, + Text: "world", + }, nil +} + +// A create author argument +type CreateAuthorArguments struct { + Name string `json:"name"` +} + +// A create authors argument +type CreateAuthorsArguments struct { + Names []string `json:"names"` +} + +// A create author result +type CreateAuthorResult struct { + ID int `json:"id"` + Name string `json:"name"` + CreatedAt time.Time `json:"created_at"` +} + +// ProcedureCreateAuthor creates an author +func ProcedureCreateAuthor(ctx context.Context, state *types.State, arguments *CreateAuthorArguments) (*CreateAuthorResult, error) { + return &CreateAuthorResult{ + ID: 1, + Name: arguments.Name, + }, nil +} + +// ProcedureCreateAuthors creates a list of authors +func ProcedureCreateAuthors(ctx context.Context, state *types.State, arguments *CreateAuthorsArguments) ([]CreateAuthorResult, error) { + return []CreateAuthorResult{ + { + ID: 1, + Name: strings.Join(arguments.Names, ","), + }, + }, nil +} + +// FunctionGetBool return an scalar boolean +func FunctionGetBool(ctx context.Context, state *types.State) (bool, error) { + return true, nil +} + +type GetTypesArguments struct { + UUID uuid.UUID + Bool bool + String string + Int int + Int8 int8 + Int16 int16 + Int32 int32 + Int64 int64 + Uint uint + Uint8 uint8 + Uint16 uint16 + Uint32 uint32 + Uint64 uint64 + Float32 float32 + Float64 float64 + Time time.Time + Text Text + CustomScalar CommentText + Enum SomeEnum + BigInt scalar.BigInt + URL scalar.URL + + UUIDPtr *uuid.UUID + BoolPtr *bool + StringPtr *string + IntPtr *int + Int8Ptr *int8 + Int16Ptr *int16 + Int32Ptr *int32 + Int64Ptr *int64 + UintPtr *uint + Uint8Ptr *uint8 + Uint16Ptr *uint16 + Uint32Ptr *uint32 + Uint64Ptr *uint64 + Float32Ptr *float32 + Float64Ptr *float64 + TimePtr *time.Time + TextPtr *Text + CustomScalarPtr *CommentText + EnumPtr *SomeEnum + BigIntPtr *scalar.BigInt + + ArrayBool []bool + ArrayString []string + ArrayInt []int + ArrayInt8 []int8 + ArrayInt16 []int16 + ArrayInt32 []int32 + ArrayInt64 []int64 + ArrayUint []uint + ArrayUint8 []uint8 + ArrayUint16 []uint16 + ArrayUint32 []uint32 + ArrayUint64 []uint64 + ArrayFloat32 []float32 + ArrayFloat64 []float64 + ArrayUUID []uuid.UUID + ArrayBoolPtr []*bool + ArrayStringPtr []*string + ArrayIntPtr []*int + ArrayInt8Ptr []*int8 + ArrayInt16Ptr []*int16 + ArrayInt32Ptr []*int32 + ArrayInt64Ptr []*int64 + ArrayUintPtr []*uint + ArrayUint8Ptr []*uint8 + ArrayUint16Ptr []*uint16 + ArrayUint32Ptr []*uint32 + ArrayUint64Ptr []*uint64 + ArrayFloat32Ptr []*float32 + ArrayFloat64Ptr []*float64 + ArrayUUIDPtr []*uuid.UUID + ArrayJSON []any + ArrayJSONPtr []*interface{} + ArrayRawJSON []json.RawMessage + ArrayRawJSONPtr []*json.RawMessage + ArrayBigInt []scalar.BigInt + ArrayBigIntPtr []*scalar.BigInt + ArrayTime []time.Time + ArrayTimePtr []*time.Time + + PtrArrayBool *[]bool + PtrArrayString *[]string + PtrArrayInt *[]int + PtrArrayInt8 *[]int8 + PtrArrayInt16 *[]int16 + PtrArrayInt32 *[]int32 + PtrArrayInt64 *[]int64 + PtrArrayUint *[]uint + PtrArrayUint8 *[]uint8 + PtrArrayUint16 *[]uint16 + PtrArrayUint32 *[]uint32 + PtrArrayUint64 *[]uint64 + PtrArrayFloat32 *[]float32 + PtrArrayFloat64 *[]float64 + PtrArrayUUID *[]uuid.UUID + PtrArrayBoolPtr *[]*bool + PtrArrayStringPtr *[]*string + PtrArrayIntPtr *[]*int + PtrArrayInt8Ptr *[]*int8 + PtrArrayInt16Ptr *[]*int16 + PtrArrayInt32Ptr *[]*int32 + PtrArrayInt64Ptr *[]*int64 + PtrArrayUintPtr *[]*uint + PtrArrayUint8Ptr *[]*uint8 + PtrArrayUint16Ptr *[]*uint16 + PtrArrayUint32Ptr *[]*uint32 + PtrArrayUint64Ptr *[]*uint64 + PtrArrayFloat32Ptr *[]*float32 + PtrArrayFloat64Ptr *[]*float64 + PtrArrayUUIDPtr *[]*uuid.UUID + PtrArrayJSON *[]any + PtrArrayJSONPtr *[]*interface{} + PtrArrayRawJSON *[]json.RawMessage + PtrArrayRawJSONPtr *[]*json.RawMessage + PtrArrayBigInt *[]scalar.BigInt + PtrArrayBigIntPtr *[]*scalar.BigInt + PtrArrayTime *[]time.Time + PtrArrayTimePtr *[]*time.Time + + Object struct { + ID uuid.UUID `json:"id"` + CreatedAt time.Time `json:"created_at"` + } + ObjectPtr *struct { + Long int + Lat int + } + ArrayObject []struct { + Content string `json:"content"` + } + ArrayObjectPtr *[]struct { + Content string `json:"content"` + } + NamedObject Author + NamedObjectPtr *Author + NamedArray []Author + NamedArrayPtr *[]Author + UUIDArray []uuid.UUID + + Map map[string]any + MapPtr *map[string]any + ArrayMap []map[string]any + ArrayMapPtr *[]map[string]any + + JSON any + JSONPtr *interface{} + RawJSON json.RawMessage + RawJSONPtr *json.RawMessage + Bytes scalar.Bytes + BytesPtr *scalar.Bytes +} + +func FunctionGetTypes(ctx context.Context, state *types.State, arguments *GetTypesArguments) (*GetTypesArguments, error) { + return arguments, nil +} diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/go.mod b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/go.mod new file mode 100644 index 0000000..45847a0 --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/go.mod @@ -0,0 +1,47 @@ +module github.com/hasura/ndc-codegen-test-snake-case + +go 1.21 + +require ( + github.com/google/uuid v1.6.0 + github.com/hasura/ndc-sdk-go v1.2.0 + go.opentelemetry.io/otel v1.28.0 + go.opentelemetry.io/otel/trace v1.28.0 +) + +require ( + github.com/alecthomas/kong v1.2.1 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/prometheus/client_golang v1.20.3 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.59.1 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + go.opentelemetry.io/contrib/propagators/b3 v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.28.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect + go.opentelemetry.io/proto/otlp v1.3.1 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240820151423-278611b39280 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240820151423-278611b39280 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect +) + +replace github.com/hasura/ndc-sdk-go => ../../../../../../../ diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/go.sum b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/go.sum new file mode 100644 index 0000000..2b37f7b --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/go.sum @@ -0,0 +1,91 @@ +github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= +github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/kong v1.2.1 h1:E8jH4Tsgv6wCRX2nGrdPyHDUCSG83WH2qE4XLACD33Q= +github.com/alecthomas/kong v1.2.1/go.mod h1:rKTSFhbdp3Ryefn8x5MOEprnRFQ7nlmMC01GKhehhBM= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= +github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= +github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.opentelemetry.io/contrib/propagators/b3 v1.28.0 h1:XR6CFQrQ/ttAYmTBX2loUEFGdk1h17pxYI8828dk/1Y= +go.opentelemetry.io/contrib/propagators/b3 v1.28.0/go.mod h1:DWRkzJONLquRz7OJPh2rRbZ7MugQj62rk7g6HRnEqh0= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 h1:aLmmtjRke7LPDQ3lvpFz+kNEH43faFhzW7v8BFIEydg= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0/go.mod h1:TC1pyCt6G9Sjb4bQpShH+P5R53pO6ZuGnHuuln9xMeE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6ZXmNPRR8ul6i3WgFURCHzaXjHdm0karRG/+dj3s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0 h1:2Ewsda6hejmbhGFyUvWZjUThC98Cf8Zy6g0zkIimOng= +go.opentelemetry.io/otel/exporters/prometheus v0.50.0/go.mod h1:pMm5PkUo5YwbLiuEf7t2xg4wbP0/eSJrMxIMxKosynY= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +google.golang.org/genproto/googleapis/api v0.0.0-20240820151423-278611b39280 h1:YDFM9oOjiFhaMAVgbDxfxW+66nRrsvzQzJ51wp3OxC0= +google.golang.org/genproto/googleapis/api v0.0.0-20240820151423-278611b39280/go.mod h1:fO8wJzT2zbQbAjbIoos1285VfEIYKDDY+Dt+WpTkh6g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240820151423-278611b39280 h1:XQMA2e105XNlEZ8NRF0HqnUOZzP14sUSsgL09kpdNnU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240820151423-278611b39280/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/types/connector.go b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/types/connector.go new file mode 100644 index 0000000..e02a82d --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/testdata/snake_case/source/types/connector.go @@ -0,0 +1,11 @@ +package types + +import "github.com/hasura/ndc-sdk-go/connector" + +// Configuration contains required settings for the connector. +type Configuration struct{} + +// State is the global state which is shared for every connector request. +type State struct { + *connector.TelemetryState +} diff --git a/cmd/hasura-ndc-go/command/internal/types.go b/cmd/hasura-ndc-go/command/internal/types.go new file mode 100644 index 0000000..48856c8 --- /dev/null +++ b/cmd/hasura-ndc-go/command/internal/types.go @@ -0,0 +1,33 @@ +package internal + +import ( + "fmt" + "slices" +) + +// OperationNamingStyle the enum for operation naming style +type OperationNamingStyle string + +const ( + StyleCamelCase OperationNamingStyle = "camel-case" + StyleSnakeCase OperationNamingStyle = "snake-case" +) + +var enumValues_OperationNamingStyle = []OperationNamingStyle{ + StyleCamelCase, StyleSnakeCase, +} + +// IsValid checks if the value is invalid +func (j OperationNamingStyle) IsValid() bool { + return slices.Contains(enumValues_OperationNamingStyle, j) +} + +// ParseOperationNamingStyle parses a OperationNamingStyle enum from string +func ParseOperationNamingStyle(input string) (OperationNamingStyle, error) { + result := OperationNamingStyle(input) + if !result.IsValid() { + return OperationNamingStyle(""), fmt.Errorf("failed to parse OperationNamingStyle, expect one of %v, got: %s", enumValues_OperationNamingStyle, input) + } + + return result, nil +} diff --git a/cmd/hasura-ndc-go/go.mod b/cmd/hasura-ndc-go/go.mod index b20ab57..32d591e 100644 --- a/cmd/hasura-ndc-go/go.mod +++ b/cmd/hasura-ndc-go/go.mod @@ -7,6 +7,7 @@ require ( github.com/fatih/structtag v1.2.0 github.com/google/uuid v1.6.0 github.com/hasura/ndc-sdk-go v1.3.0 + github.com/iancoleman/strcase v0.3.0 github.com/rs/zerolog v1.33.0 github.com/stretchr/testify v1.9.0 golang.org/x/mod v0.20.0 diff --git a/cmd/hasura-ndc-go/go.sum b/cmd/hasura-ndc-go/go.sum index 2abf103..b1e9abf 100644 --- a/cmd/hasura-ndc-go/go.sum +++ b/cmd/hasura-ndc-go/go.sum @@ -16,6 +16,8 @@ github.com/hasura/ndc-sdk-go v1.3.0 h1:xcL7hj0lPZXu9HntytlBe5pAAlCUTLqYAsPrltRUD github.com/hasura/ndc-sdk-go v1.3.0/go.mod h1:ZY+jQ7H3H1DHNcS5KkqAOxvydSkz0VnRcibd4wLz9rw= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= diff --git a/connector/cli.go b/connector/cli.go index 2825278..37cb8c7 100644 --- a/connector/cli.go +++ b/connector/cli.go @@ -47,7 +47,7 @@ type ConnectorCLI interface { // This should be the entrypoint of your connector func Start[Configuration any, State any](connector Connector[Configuration, State], options ...ServeOption) error { var cli ServeCLI - return StartCustom[Configuration, State](&cli, connector) + return StartCustom[Configuration, State](&cli, connector, options...) } // Starts the connector with custom CLI. diff --git a/connector/server.go b/connector/server.go index 9a5d254..150e3d2 100644 --- a/connector/server.go +++ b/connector/server.go @@ -52,7 +52,7 @@ func NewServer[Configuration any, State any](connector Connector[Configuration, opts(defaultOptions) } if options.ServiceName == "" { - options.ServiceName = defaultOptions.serviceName + options.OTLPConfig.ServiceName = defaultOptions.serviceName } defaultOptions.logger.Debug( "initialize OpenTelemetry", diff --git a/go.work.testing b/go.work.testing index 862ec71..c50d838 100644 --- a/go.work.testing +++ b/go.work.testing @@ -6,4 +6,5 @@ use ( cmd/hasura-ndc-go/command/internal/testdata/empty/source cmd/hasura-ndc-go/command/internal/testdata/basic/source cmd/hasura-ndc-go/command/internal/testdata/subdir/source + cmd/hasura-ndc-go/command/internal/testdata/snake_case/source )