@@ -45,6 +45,7 @@ func (e SessionRequirement) IsValid() bool {
|
||||
case SessionRequirementPresent, SessionRequirementNone, SessionRequirementOptional:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -62,6 +63,7 @@ func (e *SessionRequirement) UnmarshalGQL(v any) error {
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid SessionRequirement", str)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -74,12 +76,14 @@ func (e *SessionRequirement) UnmarshalJSON(b []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return e.UnmarshalGQL(s)
|
||||
}
|
||||
|
||||
func (e SessionRequirement) MarshalJSON() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
e.MarshalGQL(&buf)
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ func Invalid(ctx context.Context, err error) *gqlerror.Error {
|
||||
"value": errValidation.Value,
|
||||
}
|
||||
}
|
||||
|
||||
extensions := map[string]any{"code": "INVALID"}
|
||||
if details != nil {
|
||||
maps.Copy(extensions, details)
|
||||
@@ -175,6 +176,7 @@ func InvalidValidationErrors(ctx context.Context, errs validator.ValidationError
|
||||
for _, ve := range errs {
|
||||
gqlErrors = append(gqlErrors, Invalid(ctx, ve))
|
||||
}
|
||||
|
||||
return gqlErrors
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ var (
|
||||
)
|
||||
|
||||
func WithHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) context.Context {
|
||||
|
||||
ctx = context.WithValue(ctx, httpResponseWriterKey, w)
|
||||
ctx = context.WithValue(ctx, httpRequestKey, r)
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ func (t TracingExtension) InterceptField(ctx context.Context, next graphql.Resol
|
||||
)
|
||||
|
||||
result, err := next(ctx)
|
||||
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
}
|
||||
@@ -76,10 +75,12 @@ func (t TracingExtension) InterceptOperation(ctx context.Context, next graphql.O
|
||||
|
||||
rootSpan := trace.SpanFromContext(ctx)
|
||||
spanCtx := ctx
|
||||
|
||||
var operationSpan trace.Span
|
||||
|
||||
if rootSpan.IsRecording() {
|
||||
tracer := otel.Tracer("graphql-operation")
|
||||
|
||||
operationName := "GraphQL Operation"
|
||||
if requestContext.OperationName != "" {
|
||||
operationName = "GraphQL " + requestContext.OperationName
|
||||
@@ -108,6 +109,7 @@ func (t TracingExtension) InterceptOperation(ctx context.Context, next graphql.O
|
||||
duration := time.Since(startTime)
|
||||
|
||||
operationType := string(requestContext.Operation.Operation)
|
||||
|
||||
operationName := requestContext.OperationName
|
||||
if operationName == "" {
|
||||
operationName = "unnamed"
|
||||
|
||||
@@ -37,6 +37,7 @@ func UnmarshalBigIntScalar(v any) (int64, error) {
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid BigInt value: %v", err)
|
||||
}
|
||||
|
||||
return i, nil
|
||||
case int:
|
||||
return int64(val), nil
|
||||
@@ -48,11 +49,13 @@ func UnmarshalBigIntScalar(v any) (int64, error) {
|
||||
if val != float32(int64(val)) {
|
||||
return 0, fmt.Errorf("BigInt cannot represent non-integer value: %v", val)
|
||||
}
|
||||
|
||||
return int64(val), nil
|
||||
case float64:
|
||||
if val != float64(int64(val)) {
|
||||
return 0, fmt.Errorf("BigInt cannot represent non-integer value: %v", val)
|
||||
}
|
||||
|
||||
return int64(val), nil
|
||||
default:
|
||||
return 0, fmt.Errorf("cannot unmarshal %T into BigInt", v)
|
||||
|
||||
Reference in New Issue
Block a user