In the previous posts, we have seen parsing JSON and XML values using User Defined Function.
Let’s check how to delete Scalar Array values with User Defined Function.
Example
- Use deleteScalars function as a Groovy function to delete data in a scalar array.
- Suppose we have following data type with
yearlyMarks
field as scalar array.
type StudentInformation {
name : String
dob: DateTime
address: Address
standard: String
division: String
contact: Int
yearlyMarks: [Float]
}
-
deleteStudentMarks
function below deletes the given marks from the scalar array (yearlyMarks
).
type Mutation {
deleteStudentMarks( type: HypiMutationType! field: String! values: [String!]! arcql: String! ): Int!
@tan(type:Groovy, inline: """return deleteScalars(type, field, values, arcql)""")
}
Let’s execute the function!
mutation{
deleteStudentMarks(
type:StudentInformation,
field:"yearlyMarks",
values:["90.0","89.1"],
arcql:"hypi.id ='01FRQBPHEN0GWXDTDAQ7WSTAC1'"
)
}
#result
{
"data": {
"deleteStudentMarks": 2
}
}