How to use introspectSchema method of generated Package

Best Keploy code snippet using generated.introspectSchema

generated.go

Source:generated.go Github

copy

Full Screen

...165 return ec._Product(field.Selections, &res)166 })167}168func (ec *executionContext) _Query___schema(field graphql.CollectedField) graphql.Marshaler {169 res := ec.introspectSchema()170 if res == nil {171 return graphql.Null172 }173 return ec.___Schema(field.Selections, res)174}175func (ec *executionContext) _Query___type(field graphql.CollectedField) graphql.Marshaler {176 var arg0 string177 if tmp, ok := field.Args["name"]; ok {178 var err error179 arg0, err = graphql.UnmarshalString(tmp)180 if err != nil {181 ec.Error(err)182 return graphql.Null183 }184 }185 res := ec.introspectType(arg0)186 if res == nil {187 return graphql.Null188 }189 return ec.___Type(field.Selections, res)190}191var __DirectiveImplementors = []string{"__Directive"}192// nolint: gocyclo, errcheck, gas, goconst193func (ec *executionContext) ___Directive(sel []query.Selection, obj *introspection.Directive) graphql.Marshaler {194 fields := graphql.CollectFields(ec.doc, sel, __DirectiveImplementors, ec.variables)195 out := graphql.NewOrderedMap(len(fields))196 for i, field := range fields {197 out.Keys[i] = field.Alias198 switch field.Name {199 case "__typename":200 out.Values[i] = graphql.MarshalString("__Directive")201 case "name":202 out.Values[i] = ec.___Directive_name(field, obj)203 case "description":204 out.Values[i] = ec.___Directive_description(field, obj)205 case "locations":206 out.Values[i] = ec.___Directive_locations(field, obj)207 case "args":208 out.Values[i] = ec.___Directive_args(field, obj)209 default:210 panic("unknown field " + strconv.Quote(field.Name))211 }212 }213 return out214}215func (ec *executionContext) ___Directive_name(field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler {216 res := obj.Name()217 return graphql.MarshalString(res)218}219func (ec *executionContext) ___Directive_description(field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler {220 res := obj.Description()221 if res == nil {222 return graphql.Null223 }224 return graphql.MarshalString(*res)225}226func (ec *executionContext) ___Directive_locations(field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler {227 res := obj.Locations()228 arr1 := graphql.Array{}229 for idx1 := range res {230 arr1 = append(arr1, func() graphql.Marshaler { return graphql.MarshalString(res[idx1]) }())231 }232 return arr1233}234func (ec *executionContext) ___Directive_args(field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler {235 res := obj.Args()236 arr1 := graphql.Array{}237 for idx1 := range res {238 arr1 = append(arr1, func() graphql.Marshaler {239 if res[idx1] == nil {240 return graphql.Null241 }242 return ec.___InputValue(field.Selections, res[idx1])243 }())244 }245 return arr1246}247var __EnumValueImplementors = []string{"__EnumValue"}248// nolint: gocyclo, errcheck, gas, goconst249func (ec *executionContext) ___EnumValue(sel []query.Selection, obj *introspection.EnumValue) graphql.Marshaler {250 fields := graphql.CollectFields(ec.doc, sel, __EnumValueImplementors, ec.variables)251 out := graphql.NewOrderedMap(len(fields))252 for i, field := range fields {253 out.Keys[i] = field.Alias254 switch field.Name {255 case "__typename":256 out.Values[i] = graphql.MarshalString("__EnumValue")257 case "name":258 out.Values[i] = ec.___EnumValue_name(field, obj)259 case "description":260 out.Values[i] = ec.___EnumValue_description(field, obj)261 case "isDeprecated":262 out.Values[i] = ec.___EnumValue_isDeprecated(field, obj)263 case "deprecationReason":264 out.Values[i] = ec.___EnumValue_deprecationReason(field, obj)265 default:266 panic("unknown field " + strconv.Quote(field.Name))267 }268 }269 return out270}271func (ec *executionContext) ___EnumValue_name(field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler {272 res := obj.Name()273 return graphql.MarshalString(res)274}275func (ec *executionContext) ___EnumValue_description(field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler {276 res := obj.Description()277 if res == nil {278 return graphql.Null279 }280 return graphql.MarshalString(*res)281}282func (ec *executionContext) ___EnumValue_isDeprecated(field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler {283 res := obj.IsDeprecated()284 return graphql.MarshalBoolean(res)285}286func (ec *executionContext) ___EnumValue_deprecationReason(field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler {287 res := obj.DeprecationReason()288 if res == nil {289 return graphql.Null290 }291 return graphql.MarshalString(*res)292}293var __FieldImplementors = []string{"__Field"}294// nolint: gocyclo, errcheck, gas, goconst295func (ec *executionContext) ___Field(sel []query.Selection, obj *introspection.Field) graphql.Marshaler {296 fields := graphql.CollectFields(ec.doc, sel, __FieldImplementors, ec.variables)297 out := graphql.NewOrderedMap(len(fields))298 for i, field := range fields {299 out.Keys[i] = field.Alias300 switch field.Name {301 case "__typename":302 out.Values[i] = graphql.MarshalString("__Field")303 case "name":304 out.Values[i] = ec.___Field_name(field, obj)305 case "description":306 out.Values[i] = ec.___Field_description(field, obj)307 case "args":308 out.Values[i] = ec.___Field_args(field, obj)309 case "type":310 out.Values[i] = ec.___Field_type(field, obj)311 case "isDeprecated":312 out.Values[i] = ec.___Field_isDeprecated(field, obj)313 case "deprecationReason":314 out.Values[i] = ec.___Field_deprecationReason(field, obj)315 default:316 panic("unknown field " + strconv.Quote(field.Name))317 }318 }319 return out320}321func (ec *executionContext) ___Field_name(field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler {322 res := obj.Name()323 return graphql.MarshalString(res)324}325func (ec *executionContext) ___Field_description(field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler {326 res := obj.Description()327 if res == nil {328 return graphql.Null329 }330 return graphql.MarshalString(*res)331}332func (ec *executionContext) ___Field_args(field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler {333 res := obj.Args()334 arr1 := graphql.Array{}335 for idx1 := range res {336 arr1 = append(arr1, func() graphql.Marshaler {337 if res[idx1] == nil {338 return graphql.Null339 }340 return ec.___InputValue(field.Selections, res[idx1])341 }())342 }343 return arr1344}345func (ec *executionContext) ___Field_type(field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler {346 res := obj.Type()347 if res == nil {348 return graphql.Null349 }350 return ec.___Type(field.Selections, res)351}352func (ec *executionContext) ___Field_isDeprecated(field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler {353 res := obj.IsDeprecated()354 return graphql.MarshalBoolean(res)355}356func (ec *executionContext) ___Field_deprecationReason(field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler {357 res := obj.DeprecationReason()358 if res == nil {359 return graphql.Null360 }361 return graphql.MarshalString(*res)362}363var __InputValueImplementors = []string{"__InputValue"}364// nolint: gocyclo, errcheck, gas, goconst365func (ec *executionContext) ___InputValue(sel []query.Selection, obj *introspection.InputValue) graphql.Marshaler {366 fields := graphql.CollectFields(ec.doc, sel, __InputValueImplementors, ec.variables)367 out := graphql.NewOrderedMap(len(fields))368 for i, field := range fields {369 out.Keys[i] = field.Alias370 switch field.Name {371 case "__typename":372 out.Values[i] = graphql.MarshalString("__InputValue")373 case "name":374 out.Values[i] = ec.___InputValue_name(field, obj)375 case "description":376 out.Values[i] = ec.___InputValue_description(field, obj)377 case "type":378 out.Values[i] = ec.___InputValue_type(field, obj)379 case "defaultValue":380 out.Values[i] = ec.___InputValue_defaultValue(field, obj)381 default:382 panic("unknown field " + strconv.Quote(field.Name))383 }384 }385 return out386}387func (ec *executionContext) ___InputValue_name(field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler {388 res := obj.Name()389 return graphql.MarshalString(res)390}391func (ec *executionContext) ___InputValue_description(field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler {392 res := obj.Description()393 if res == nil {394 return graphql.Null395 }396 return graphql.MarshalString(*res)397}398func (ec *executionContext) ___InputValue_type(field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler {399 res := obj.Type()400 if res == nil {401 return graphql.Null402 }403 return ec.___Type(field.Selections, res)404}405func (ec *executionContext) ___InputValue_defaultValue(field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler {406 res := obj.DefaultValue()407 if res == nil {408 return graphql.Null409 }410 return graphql.MarshalString(*res)411}412var __SchemaImplementors = []string{"__Schema"}413// nolint: gocyclo, errcheck, gas, goconst414func (ec *executionContext) ___Schema(sel []query.Selection, obj *introspection.Schema) graphql.Marshaler {415 fields := graphql.CollectFields(ec.doc, sel, __SchemaImplementors, ec.variables)416 out := graphql.NewOrderedMap(len(fields))417 for i, field := range fields {418 out.Keys[i] = field.Alias419 switch field.Name {420 case "__typename":421 out.Values[i] = graphql.MarshalString("__Schema")422 case "types":423 out.Values[i] = ec.___Schema_types(field, obj)424 case "queryType":425 out.Values[i] = ec.___Schema_queryType(field, obj)426 case "mutationType":427 out.Values[i] = ec.___Schema_mutationType(field, obj)428 case "subscriptionType":429 out.Values[i] = ec.___Schema_subscriptionType(field, obj)430 case "directives":431 out.Values[i] = ec.___Schema_directives(field, obj)432 default:433 panic("unknown field " + strconv.Quote(field.Name))434 }435 }436 return out437}438func (ec *executionContext) ___Schema_types(field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler {439 res := obj.Types()440 arr1 := graphql.Array{}441 for idx1 := range res {442 arr1 = append(arr1, func() graphql.Marshaler {443 if res[idx1] == nil {444 return graphql.Null445 }446 return ec.___Type(field.Selections, res[idx1])447 }())448 }449 return arr1450}451func (ec *executionContext) ___Schema_queryType(field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler {452 res := obj.QueryType()453 if res == nil {454 return graphql.Null455 }456 return ec.___Type(field.Selections, res)457}458func (ec *executionContext) ___Schema_mutationType(field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler {459 res := obj.MutationType()460 if res == nil {461 return graphql.Null462 }463 return ec.___Type(field.Selections, res)464}465func (ec *executionContext) ___Schema_subscriptionType(field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler {466 res := obj.SubscriptionType()467 if res == nil {468 return graphql.Null469 }470 return ec.___Type(field.Selections, res)471}472func (ec *executionContext) ___Schema_directives(field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler {473 res := obj.Directives()474 arr1 := graphql.Array{}475 for idx1 := range res {476 arr1 = append(arr1, func() graphql.Marshaler {477 if res[idx1] == nil {478 return graphql.Null479 }480 return ec.___Directive(field.Selections, res[idx1])481 }())482 }483 return arr1484}485var __TypeImplementors = []string{"__Type"}486// nolint: gocyclo, errcheck, gas, goconst487func (ec *executionContext) ___Type(sel []query.Selection, obj *introspection.Type) graphql.Marshaler {488 fields := graphql.CollectFields(ec.doc, sel, __TypeImplementors, ec.variables)489 out := graphql.NewOrderedMap(len(fields))490 for i, field := range fields {491 out.Keys[i] = field.Alias492 switch field.Name {493 case "__typename":494 out.Values[i] = graphql.MarshalString("__Type")495 case "kind":496 out.Values[i] = ec.___Type_kind(field, obj)497 case "name":498 out.Values[i] = ec.___Type_name(field, obj)499 case "description":500 out.Values[i] = ec.___Type_description(field, obj)501 case "fields":502 out.Values[i] = ec.___Type_fields(field, obj)503 case "interfaces":504 out.Values[i] = ec.___Type_interfaces(field, obj)505 case "possibleTypes":506 out.Values[i] = ec.___Type_possibleTypes(field, obj)507 case "enumValues":508 out.Values[i] = ec.___Type_enumValues(field, obj)509 case "inputFields":510 out.Values[i] = ec.___Type_inputFields(field, obj)511 case "ofType":512 out.Values[i] = ec.___Type_ofType(field, obj)513 default:514 panic("unknown field " + strconv.Quote(field.Name))515 }516 }517 return out518}519func (ec *executionContext) ___Type_kind(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {520 res := obj.Kind()521 return graphql.MarshalString(res)522}523func (ec *executionContext) ___Type_name(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {524 res := obj.Name()525 if res == nil {526 return graphql.Null527 }528 return graphql.MarshalString(*res)529}530func (ec *executionContext) ___Type_description(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {531 res := obj.Description()532 if res == nil {533 return graphql.Null534 }535 return graphql.MarshalString(*res)536}537func (ec *executionContext) ___Type_fields(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {538 var arg0 bool539 if tmp, ok := field.Args["includeDeprecated"]; ok {540 var err error541 arg0, err = graphql.UnmarshalBoolean(tmp)542 if err != nil {543 ec.Error(err)544 return graphql.Null545 }546 }547 res := obj.Fields(arg0)548 arr1 := graphql.Array{}549 for idx1 := range res {550 arr1 = append(arr1, func() graphql.Marshaler {551 if res[idx1] == nil {552 return graphql.Null553 }554 return ec.___Field(field.Selections, res[idx1])555 }())556 }557 return arr1558}559func (ec *executionContext) ___Type_interfaces(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {560 res := obj.Interfaces()561 arr1 := graphql.Array{}562 for idx1 := range res {563 arr1 = append(arr1, func() graphql.Marshaler {564 if res[idx1] == nil {565 return graphql.Null566 }567 return ec.___Type(field.Selections, res[idx1])568 }())569 }570 return arr1571}572func (ec *executionContext) ___Type_possibleTypes(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {573 res := obj.PossibleTypes()574 arr1 := graphql.Array{}575 for idx1 := range res {576 arr1 = append(arr1, func() graphql.Marshaler {577 if res[idx1] == nil {578 return graphql.Null579 }580 return ec.___Type(field.Selections, res[idx1])581 }())582 }583 return arr1584}585func (ec *executionContext) ___Type_enumValues(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {586 var arg0 bool587 if tmp, ok := field.Args["includeDeprecated"]; ok {588 var err error589 arg0, err = graphql.UnmarshalBoolean(tmp)590 if err != nil {591 ec.Error(err)592 return graphql.Null593 }594 }595 res := obj.EnumValues(arg0)596 arr1 := graphql.Array{}597 for idx1 := range res {598 arr1 = append(arr1, func() graphql.Marshaler {599 if res[idx1] == nil {600 return graphql.Null601 }602 return ec.___EnumValue(field.Selections, res[idx1])603 }())604 }605 return arr1606}607func (ec *executionContext) ___Type_inputFields(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {608 res := obj.InputFields()609 arr1 := graphql.Array{}610 for idx1 := range res {611 arr1 = append(arr1, func() graphql.Marshaler {612 if res[idx1] == nil {613 return graphql.Null614 }615 return ec.___InputValue(field.Selections, res[idx1])616 }())617 }618 return arr1619}620func (ec *executionContext) ___Type_ofType(field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler {621 res := obj.OfType()622 if res == nil {623 return graphql.Null624 }625 return ec.___Type(field.Selections, res)626}627var parsedSchema = schema.MustParse("schema {\n\t\tquery: Query\n\t\tmutation: Mutation\n\t}\n\ntype Query {\n product(id: Int!): Product!\n}\n\ntype Mutation {\n createProduct(name: String!): Product!\n}\n\ntype Product {\n id: Int!\n name: String!\n}\n")628func (ec *executionContext) introspectSchema() *introspection.Schema {629 return introspection.WrapSchema(parsedSchema)630}631func (ec *executionContext) introspectType(name string) *introspection.Type {632 t := parsedSchema.Resolve(name)633 if t == nil {634 return nil635 }636 return introspection.WrapType(t)637}...

Full Screen

Full Screen

localdocker.go

Source:localdocker.go Github

copy

Full Screen

1package workspace2import (3 "errors"4 "fmt"5 "net/url"6 "strings"7 "sync"8 "github.com/jmoiron/sqlx"9 log "github.com/sirupsen/logrus"10 "github.com/skeema/skeema/internal/tengo"11)12// LocalDocker is a Workspace created inside of a Docker container on localhost.13// The schema is dropped when done interacting with the workspace in Cleanup(),14// but the container remains running. The container may optionally be stopped15// or destroyed via Shutdown().16type LocalDocker struct {17 schemaName string18 d *tengo.DockerizedInstance19 releaseLock releaseFunc20 cleanupAction CleanupAction21 defaultConnParams string22}23var cstore struct {24 dockerClient *tengo.DockerClient25 containers map[string]*tengo.DockerizedInstance26 sync.Mutex27}28// NewLocalDocker finds or creates a containerized MySQL instance, creates a29// temporary schema on it, and returns it.30func NewLocalDocker(opts Options) (ld *LocalDocker, err error) {31 if !opts.Flavor.Supported() {32 return nil, fmt.Errorf("NewLocalDocker: unsupported flavor %s", opts.Flavor)33 }34 cstore.Lock()35 defer cstore.Unlock()36 if cstore.dockerClient == nil {37 if cstore.dockerClient, err = tengo.NewDockerClient(tengo.DockerClientOptions{}); err != nil {38 return39 }40 cstore.containers = make(map[string]*tengo.DockerizedInstance)41 tengo.UseFilteredDriverLogger()42 }43 ld = &LocalDocker{44 schemaName: opts.SchemaName,45 cleanupAction: opts.CleanupAction,46 defaultConnParams: opts.DefaultConnParams,47 }48 image := opts.Flavor.String()49 if arch, _ := cstore.dockerClient.ServerArchitecture(); arch == "arm64" && opts.Flavor.IsMySQL() {50 // MySQL 8 images are available for arm64 on DockerHub, but via51 // mysql/mysql-server rather than _/mysql. Pre-8 MySQL, or any version52 // of Percona Server, are not available.53 if opts.Flavor.Min(tengo.FlavorMySQL80) && opts.Flavor.Variants == tengo.VariantNone {54 image = strings.Replace(image, "mysql:", "mysql/mysql-server:", 1)55 } else {56 log.Warnf("Official arm64 Docker images for %s are not available. Substituting mysql/mysql-server:8.0 instead for workspace purposes, which may cause behavior differences.", image)57 opts.ContainerName = strings.Replace(opts.ContainerName, tengo.ContainerNameForImage(image), "mysql-8.0", 1)58 image = "mysql/mysql-server:8.0"59 }60 }61 if opts.ContainerName == "" {62 opts.ContainerName = "skeema-" + tengo.ContainerNameForImage(image)63 }64 if cstore.containers[opts.ContainerName] != nil {65 ld.d = cstore.containers[opts.ContainerName]66 } else {67 var commandArgs []string68 // If real inst had lower_case_table_names=1, use that in the container as69 // well. (No need for similar logic with lower_case_table_names=2; this cannot70 // be used on Linux, and code in ExecLogicalSchema already gets us close71 // enough to this mode's behavior.)72 if opts.NameCaseMode == tengo.NameCaseLower {73 commandArgs = append(commandArgs, "--lower-case-table-names=1")74 }75 log.Infof("Using container %s (image=%s) for workspace operations", opts.ContainerName, image)76 ld.d, err = cstore.dockerClient.GetOrCreateInstance(tengo.DockerizedInstanceOptions{77 Name: opts.ContainerName,78 Image: image,79 RootPassword: opts.RootPassword,80 DefaultConnParams: "", // intentionally not set here; see important comment in ConnectionPool()81 CommandArgs: commandArgs,82 })83 if ld.d != nil {84 cstore.containers[opts.ContainerName] = ld.d85 RegisterShutdownFunc(ld.shutdown)86 }87 if err != nil {88 return nil, err89 }90 }91 lockName := fmt.Sprintf("skeema.%s", ld.schemaName)92 if ld.releaseLock, err = getLock(ld.d.Instance, lockName, opts.LockWaitTimeout); err != nil {93 return nil, fmt.Errorf("Unable to obtain lock on %s: %s", ld.d.Instance, err)94 }95 // If this function errors, don't continue to hold the lock96 defer func() {97 if err != nil {98 ld.releaseLock()99 ld = nil100 }101 }()102 if has, err := ld.d.HasSchema(ld.schemaName); err != nil {103 return ld, fmt.Errorf("Unable to check for existence of temp schema on %s: %s", ld.d.Instance, err)104 } else if has {105 // Attempt to drop the schema, so we can recreate it below. (This is safer106 // than attempting to re-use the schema.) Fail if any tables actually have107 // 1 or more rows.108 dropOpts := tengo.BulkDropOptions{109 MaxConcurrency: 10,110 OnlyIfEmpty: true,111 SkipBinlog: true,112 }113 if err := ld.d.DropSchema(ld.schemaName, dropOpts); err != nil {114 return ld, fmt.Errorf("Cannot drop existing temporary schema on %s: %s", ld.d.Instance, err)115 }116 }117 createOpts := tengo.SchemaCreationOptions{118 DefaultCharSet: opts.DefaultCharacterSet,119 DefaultCollation: opts.DefaultCollation,120 SkipBinlog: true,121 }122 _, err = ld.d.CreateSchema(ld.schemaName, createOpts)123 if err != nil {124 return ld, fmt.Errorf("Cannot create temporary schema on %s: %s", ld.d.Instance, err)125 }126 return ld, nil127}128// ConnectionPool returns a connection pool (*sqlx.DB) to the temporary129// workspace schema, using the supplied connection params (which may be blank).130func (ld *LocalDocker) ConnectionPool(params string) (*sqlx.DB, error) {131 // User-configurable default connection params are stored in the LocalDocker132 // value, NOT in the tengo.DockerizedInstance. This permits re-use of the same133 // DockerizedInstance in multiple LocalDocker workspaces, even if the134 // workspaces have different connection params (e.g. due to being generated by135 // different sibling subdirectories with differing configurations).136 // So, here we must merge the params arg (callsite-dependent) over top of the137 // LocalDocker params (dir-dependent).138 var finalParams string139 if ld.defaultConnParams == "" && params == "" {140 // By default, disable TLS for connections to the DockerizedInstance, since141 // we know it's on the local machine142 finalParams = "tls=false"143 } else {144 v, err := url.ParseQuery(ld.defaultConnParams)145 if err != nil {146 return nil, err147 }148 // Forcibly disable TLS, regardless of what was in ld.defaultConnParams.149 // This is necessary since ld.defaultConnParams is typically populated using150 // Dir.InstanceDefaultParams() which sets tls=preferred by default.151 v.Set("tls", "false")152 // Apply overrides from params arg153 overrides, err := url.ParseQuery(params)154 if err != nil {155 return nil, err156 }157 for name := range overrides {158 v.Set(name, overrides.Get(name))159 }160 finalParams = v.Encode()161 }162 return ld.d.CachedConnectionPool(ld.schemaName, finalParams)163}164// IntrospectSchema introspects and returns the temporary workspace schema.165func (ld *LocalDocker) IntrospectSchema() (*tengo.Schema, error) {166 return ld.d.Schema(ld.schemaName)167}168// Cleanup drops the temporary schema from the Dockerized instance. If any169// tables have any rows in the temp schema, the cleanup aborts and an error is170// returned.171// Cleanup does not handle stopping or destroying the container. If requested,172// that is handled by Shutdown() instead, so that containers aren't needlessly173// created and stopped/destroyed multiple times during a program's execution.174func (ld *LocalDocker) Cleanup(schema *tengo.Schema) error {175 if ld.releaseLock == nil {176 return errors.New("Cleanup() called multiple times on same LocalDocker")177 }178 defer func() {179 ld.releaseLock()180 ld.releaseLock = nil181 }()182 dropOpts := tengo.BulkDropOptions{183 MaxConcurrency: 10,184 OnlyIfEmpty: true,185 SkipBinlog: true,186 Schema: schema, // may be nil, not a problem187 }188 if err := ld.d.DropSchema(ld.schemaName, dropOpts); err != nil {189 return fmt.Errorf("Cannot drop temporary schema on %s: %s", ld.d.Instance, err)190 }191 return nil192}193// shutdown handles shutdown logic for a specific LocalDocker instance. A single194// string arg may optionally be supplied as a container name prefix: if the195// container name does not begin with the prefix, no shutdown occurs.196func (ld *LocalDocker) shutdown(args ...interface{}) bool {197 if len(args) > 0 {198 if prefix, ok := args[0].(string); !ok || !strings.HasPrefix(ld.d.Name, prefix) {199 return false200 }201 }202 cstore.Lock()203 defer cstore.Unlock()204 if ld.cleanupAction == CleanupActionStop {205 log.Infof("Stopping container %s", ld.d.Name)206 if err := ld.d.Stop(); err != nil {207 log.Warnf("Failed to stop container %s: %v", ld.d.Name, err)208 }209 } else if ld.cleanupAction == CleanupActionDestroy {210 log.Infof("Destroying container %s", ld.d.Name)211 if err := ld.d.Destroy(); err != nil {212 log.Warnf("Failed to destroy container %s: %v", ld.d.Name, err)213 }214 }215 delete(cstore.containers, ld.d.Name)216 return true217}...

Full Screen

Full Screen

introspectSchema

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 http.Handle("/", handler.Playground("GraphQL playground", "/query"))4 http.Handle("/query", handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}})))5 log.Fatal(http.ListenAndServe(":8080", nil))6}7type Resolver struct{}8func (r *Resolver) IntrospectSchema(ctx context.Context) (*ast.Schema, error) {9 return graphql.GetRequestContext(ctx).IntrospectionSchema, nil10}11type Query struct {12}13func (r *Resolver) Query() QueryResolver {14 return &Query{r}15}16type QueryResolver interface {17 IntrospectSchema(ctx context.Context) (*ast.Schema, error)18}19func (r *Query) IntrospectSchema(ctx context.Context) (*ast.Schema, error) {20 return r.Resolver.IntrospectSchema(ctx)21}22import (23func main() {24 http.Handle("/", handler.Playground("GraphQL playground", "/query"))25 http.Handle("/query", handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}})))26 log.Fatal(http.ListenAndServe(":8080", nil))27}28type Resolver struct{}29func (r *Resolver) IntrospectSchema(ctx context.Context) (*ast.Schema, error) {30 return graphql.GetRequestContext(ctx).IntrospectionSchema, nil31}32type Query struct {33}34func (r *Resolver) Query() QueryResolver {35 return &Query{r}36}37type QueryResolver interface {38 IntrospectSchema(ctx context.Context) (*ast.Schema, error)39}40func (r *Query) IntrospectSchema(ctx context.Context) (*ast.Schema, error) {41 return r.Resolver.IntrospectSchema(ctx)42}

Full Screen

Full Screen

introspectSchema

Using AI Code Generation

copy

Full Screen

1import (2 "github.com/wso2/product-apim-tooling/import-export-cli/vendor/github.com/wso2/product-apim-tooling/import-export-cli/integration/testutils/apim"3func main() {4 APIProduct := apim.APIProduct{5 Transport: []string{"http", "https"},6 Tags: []string{"pizza", "pizzashack", "order"},7 Environments: []string{"Production and Sandbox"},8 BusinessInformation: apim.BusinessInformation{

Full Screen

Full Screen

introspectSchema

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 client := pkg.NewClient("localhost", 48082)4 deviceService, err := client.DeviceServiceClient.DeviceServiceForName("Random-Integer-Device")5 if err != nil {6 fmt.Println(err)7 }8 device, err := client.DeviceClient.DeviceForName("Random-Integer-Device")9 if err != nil {10 fmt.Println(err)11 }12 deviceProfile, err := client.DeviceProfileClient.DeviceProfileForName("Random-Integer-Device")13 if err != nil {14 fmt.Println(err)15 }16 devices, err := client.DeviceClient.AllDevices()17 if err != nil {18 fmt.Println(err)19 }20 deviceServices, err := client.DeviceServiceClient.AllDeviceServices()21 if err != nil {22 fmt.Println(err)23 }24 deviceProfiles, err := client.DeviceProfileClient.AllDeviceProfiles()25 if err != nil {26 fmt.Println(err)27 }28 devicesByProfile, err := client.DeviceClient.DevicesForProfileName("Random-Integer-Device")29 if err != nil {30 fmt.Println(err)31 }32 devicesByService, err := client.DeviceClient.DevicesForServiceName("Random-Integer-Device")33 if err != nil {34 fmt.Println(err)35 }36 devicesByLabel, err := client.DeviceClient.DevicesForLabel("Random-Integer-Device")37 if err != nil {38 fmt.Println(err)39 }

Full Screen

Full Screen

introspectSchema

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 obj := new(rpc_gen.RPC)4 result := obj.IntrospectSchema()5 fmt.Println(result)6}7[{"name":"HelloWorld","params":[{"name":"name","type":"string"},{"name":"age","type":"int"}],"returnType":"string"}]

Full Screen

Full Screen

introspectSchema

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 session, _ := client.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})4 tx, _ := session.NewTransaction()5 result, _ := tx.Run("CALL apoc.meta.schema", map[string]interface{}{})6 record, _ := result.Next()7 value, _ := record.GetByIndex(0)8 fmt.Println(value)9 tx.Close()10 session.Close()11 client.Close()12}13[MIT](LICENSE)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Keploy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful