Skip to content

Commit

Permalink
clrf
Browse files Browse the repository at this point in the history
  • Loading branch information
roneli committed Mar 14, 2024
1 parent ac99876 commit 27811fb
Show file tree
Hide file tree
Showing 17 changed files with 3,098 additions and 3,098 deletions.
72 changes: 36 additions & 36 deletions pkg/execution/builders/directives.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package builders

import (
"fmt"

"github.com/vektah/gqlparser/v2/ast"
)

type DialectDirective struct {
Dialect string
ParentDialect string
}

func GetDialectDirective(schema *ast.Schema, field Field) (*DialectDirective, error) {
typeName := field.GetTypeName()
objType, ok := schema.Types[typeName]
if !ok {
return nil, fmt.Errorf("failed to find type definition for %s", typeName)
}
parentDialect := "postgres"
pd := field.ObjectDefinition.Directives.ForName("dialect")
if pd == nil {
parentDialect = pd.Arguments.ForName("type").Value.Raw
}
d := objType.Directives.ForName("dialect")
if d == nil {
return &DialectDirective{
Dialect: "postgres",
ParentDialect: parentDialect,
}, nil
}
return &DialectDirective{
Dialect: pd.Arguments.ForName("type").Value.Raw,
ParentDialect: parentDialect,
}, nil
}
package builders

import (
"fmt"

"github.com/vektah/gqlparser/v2/ast"
)

type DialectDirective struct {
Dialect string
ParentDialect string
}

func GetDialectDirective(schema *ast.Schema, field Field) (*DialectDirective, error) {
typeName := field.GetTypeName()
objType, ok := schema.Types[typeName]
if !ok {
return nil, fmt.Errorf("failed to find type definition for %s", typeName)
}
parentDialect := "postgres"
pd := field.ObjectDefinition.Directives.ForName("dialect")
if pd == nil {
parentDialect = pd.Arguments.ForName("type").Value.Raw
}
d := objType.Directives.ForName("dialect")
if d == nil {
return &DialectDirective{
Dialect: "postgres",
ParentDialect: parentDialect,
}, nil
}
return &DialectDirective{
Dialect: pd.Arguments.ForName("type").Value.Raw,
ParentDialect: parentDialect,
}, nil
}
Loading

0 comments on commit 27811fb

Please sign in to comment.