Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
islamaliev committed Jun 28, 2024
1 parent 34bef3f commit 415b025
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 5 additions & 0 deletions internal/request/graphql/schema/descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,10 @@ Indicates as to whether or not this document has been deleted.
`
versionFieldDescription string = `
Returns the head commit for this document.
`

encryptArgDescription string = `
Encrypt flag specified if the input document(s) needs to be encrypted. If set, DefraDB will generate a
symmetric key for encryption using AES-GCM.
`
)
10 changes: 2 additions & 8 deletions internal/request/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,6 @@ func (g *Generator) GenerateMutationInputForGQLType(obj *gql.Object) ([]*gql.Fie

filterInputName := genTypeName(obj, filterInputNameSuffix)
mutationInputName := genTypeName(obj, mutationInputNameSuffix)
mutationInputsName := genTypeName(obj, mutationInputsNameSuffix)

filterInput, ok := g.manager.schema.TypeMap()[filterInputName].(*gql.InputObject)
if !ok {
Expand All @@ -1051,19 +1050,14 @@ func (g *Generator) GenerateMutationInputForGQLType(obj *gql.Object) ([]*gql.Fie
return nil, NewErrTypeNotFound(mutationInputName)
}

mutationInputs, ok := g.manager.schema.TypeMap()[mutationInputsName]
if !ok {
return nil, NewErrTypeNotFound(mutationInputsName)
}

create := &gql.Field{
Name: "create_" + obj.Name(),
Description: createDocumentDescription,
Type: obj,
Args: gql.FieldConfigArgument{
"input": schemaTypes.NewArgConfig(mutationInput, "Create field values"),
"inputs": schemaTypes.NewArgConfig(mutationInputs, "Create field values"),
"encrypt": schemaTypes.NewArgConfig(gql.Boolean, "Encrypt input document(s)"),
"inputs": schemaTypes.NewArgConfig(gql.NewList(mutationInput), "Create field values"),
"encrypt": schemaTypes.NewArgConfig(gql.Boolean, encryptArgDescription),
},
}

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/utils2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,6 @@ func createDocViaGQL(
}
require.NoError(s.t, err)

var docs []*client.Document

params := paramName + ": " + input

if action.IsEncrypted {
Expand Down Expand Up @@ -1347,15 +1345,17 @@ func createDocViaGQL(
return nil, nil
}

for _, docMap := range resultantDocs {
docs := make([]*client.Document, len(resultantDocs))

for i, docMap := range resultantDocs {
docIDString := docMap["_docID"].(string)
docID, err := client.NewDocIDFromString(docIDString)
require.NoError(s.t, err)

doc, err := collection.Get(ctx, docID, false)
require.NoError(s.t, err)

docs = append(docs, doc)
docs[i] = doc
}

return docs, nil
Expand Down

0 comments on commit 415b025

Please sign in to comment.