I am trying to parameterize a GraphQL query being sent as Body Data in JMeter, but not getting the correct response.
Here is the graphql:
{"operationName":"VPercentageQuery","variables":{"thestate":"CA"},"query":"query VPercentageQuery($thestate: [String]) {\n nodeQuery(filter: {conditions: [{operator: EQUAL, field: "type", value: "v_data"}, {operator: EQUAL, field: "field_vev_percentage_state", value: $thestate}]}, sort: {field: "field_year", direction: DESC}, limit: 3) {\n entities {\n entityLabel\n ... on NodeVData {\n fieldVevPercentageState\n fieldStatePercentage\n fieldEffectiveDateRange\n fieldYear\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"}
Now, substituting "CA" with "${state}"
{"operationName":"VPercentageQuery","variables":{"thestate":"${state}"},"query":"query VPercentageQuery($thestate: [String]) {\n nodeQuery(filter: {conditions: [{operator: EQUAL, field: "type", value: "v_data"}, {operator: EQUAL, field: "field_vev_percentage_state", value: $thestate}]}, sort: {field: "field_year", direction: DESC}, limit: 3) {\n entities {\n entityLabel\n ... on NodeVData {\n fieldVevPercentageState\n fieldStatePercentage\n fieldEffectiveDateRange\n fieldYear\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"}
Now, creating a state.csv file with just one column have entries:
CA
VA
SD
ND
and adding a CSV Data Set Config , Config Element
Not getting the response with states in the csv file
I am using JMeter 5.3
"variables": {"thestate": "${state}" } works , add CSV Data Set Config
with Ignore First Line to True ( if you have a heading, state )
and just add all states in one column, plus keep the Loop Count in the
Related
I have seen there are many questions related to mine, but unfortunately, none of them work for me. That is why I am asking my question since I am still learning GraphQL.
I am working on a Project with NestJS, GraphQL, and Angular. I am using the Apollo client and the Apollo server to implement GraphQL.My approach is code first to schema creation. I am getting an error while doing an update mutation. I am using PostgreSQL as the database
Here is the mutation section of the generated schema
type Mutation {
updateVehicle(email: String!, vinNumber: String!, lastName: String!, firstName: String!, id: Int!): Vehicle!
deleteVehicle(id: Int!): Vehicle!
}
Here is the resolver for update mutation
#Mutation(returns => Vehicle)
async updateVehicle(
#Args({name: 'id', type: () => Int }) id: number,
#Args({name: 'firstName', type: () => String }) firstName: string,
#Args({name: 'lastName', type: () => String }) lastName: string,
#Args({name: 'vinNumber', type: () => String }) vinNumber: string,
#Args({name: 'email', type: () => String }) email: string) {
....
...
}
Here is the query that I tried on the playground of the apollo server.
mutation MyMutation(
$id: Int!,
$email:String!,
$firstName:String!,
$lastName:String!,
$vinNumber:String!){
updateVehicle(
id: $id,
email: $email,
firstName: $firstName,
lastName: $lastName,
vinNumber: $vinNumber){
id
email
firstName
lastName
vinNumber
}
}
In the query variables section, I put my values like below
{
"id": 2,
"firstName":"test",
"lastName": "test2",
"vinNumber": "1234",
"email": "test#live.com"
}
When I execute the query I am getting the below error message. Actually, I cannot figure out what it means.
{
"errors": [
{
"message": "Syntax Error: Expected Name, found \")\".: {\"response\":{\"errors\":[{\"message\":\"Syntax Error: Expected Name, found \\\")\\\".\",\"locations\":[{\"line\":3,\"column\":5}]}],\"status\":400},\"request\":{\"query\":\"{updateVehicleById(\\n input: {vehiclePatch: {id: 2}\\n ) {\\n vehicle {\\n ageOfVehicle \\n carMake \\n carModel \\n email\\n firstName \\n id\\n lastName\\n manufacturedDate\\n vinNumber\\n }\\n }}\"}}",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"updateVehicle"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"response": {
"errors": [
{
"message": "Syntax Error: Expected Name, found \")\".",
"locations": [
{
"line": 3,
"column": 5
}
]
}
],
"status": 400
},
"request": {
"query": "{updateVehicleById(\n input: {vehiclePatch: {id: 2}\n ) {\n vehicle {\n ageOfVehicle \n carMake \n carModel \n email\n firstName \n id\n lastName\n manufacturedDate\n vinNumber\n }\n }}"
},
"stacktrace": [
"Error: Syntax Error: Expected Name, found \")\".: {\"response\":{\"errors\":[{\"message\":\"Syntax Error: Expected Name, found \\\")\\\".\",\"locations\":[{\"line\":3,\"column\":5}]}],\"status\":400},\"request\":{\"query\":\"{updateVehicleById(\\n input: {vehiclePatch: {id: 2}\\n ) {\\n vehicle {\\n ageOfVehicle \\n carMake \\n carModel \\n email\\n firstName \\n id\\n lastName\\n manufacturedDate\\n vinNumber\\n }\\n }}\"}}",
" at GraphQLClient.<anonymous> (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:170:35)",
" at step (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:63:23)",
" at Object.next (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:44:53)",
" at fulfilled (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:35:58)",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
}
}
}
],
"data": null
}
I put the full error message for your reference. May I know the reason for this error? I tried changing the query and mutation as well. But it doesn't work. Appreciate your helpful response.
The code in this question is wrong, but the error makes it clear what the issue is:
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"response": {
"errors": [
{
"message": "Syntax Error: Expected Name, found \")\".",
"locations": [
{
"line": 3,
"column": 5
}
]
}
],
"status": 400
},
"request": {
"query": "{updateVehicleById(\n input: {vehiclePatch: {id: 2}\n ) {\n vehicle {\n ageOfVehicle \n carMake \n carModel \n email\n firstName \n id\n lastName\n manufacturedDate\n vinNumber\n }\n }}"
},
"stacktrace": [
"Error: Syntax Error: Expected Name, found \")\".: {\"response\":{\"errors\":[{\"message\":\"Syntax Error: Expected Name, found \\\")\\\".\",\"locations\":[{\"line\":3,\"column\":5}]}],\"status\":400},\"request\":{\"query\":\"{updateVehicleById(\\n input: {vehiclePatch: {id: 2}\\n ) {\\n vehicle {\\n ageOfVehicle \\n carMake \\n carModel \\n email\\n firstName \\n id\\n lastName\\n manufacturedDate\\n vinNumber\\n }\\n }}\"}}",
" at GraphQLClient.<anonymous> (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:170:35)",
" at step (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:63:23)",
" at Object.next (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:44:53)",
" at fulfilled (E:\\Virtusa\\vehicle-managment-app\\vehicle-mgt-server3\\node_modules\\graphql-request\\dist\\index.js:35:58)",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
}
}
specifically has the request block that shows that the query throwing the error is
{updateVehicleById(
input: {vehiclePatch: {id: 2}
) {
vehicle {
ageOfVehicle
carMake
carModel
email
firstName
id
lastName
manufacturedDate
vinNumber
}
}}
The error says line 3 column 5 we can see the error is at ) { and looking closer, we can see the real error is on the previous line:
input: {vehiclePatch: {id: 2}
This input object has mismatched }, so it needs an extra } at the end of the line.
I'm using the Go implemenatation of GraphQL.
How would you configure a mutation so that it can receive arguments with more than 1 level?
For exemple, here is the list of arguments I would like to pass to a mutation CreateUser:
mutation createUser($user: CreateUser!) {
createUser(input: $user)
}
{
"user": {
"name": {
"first": "John",
"last": "Doe"
},
"email": "john#doe.com"
}
}
(Notice that I dont want to use firstname and lastname but a name object instead)
And this is my (unsuccessful) attempt so far:
var CreateUserInput = graphql.FieldConfigArgument{
"input": &graphql.ArgumentConfig{
Description: "Input for creating a new user",
Type: graphql.NewNonNull(graphql.NewInputObject(graphql.InputObjectConfig{
Name: "CreateUser",
Fields: graphql.InputObjectConfigFieldMap{
"name": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.NewInputObject(graphql.InputObjectConfig{
Fields: graphql.InputObjectConfigFieldMap{
"first": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
"last": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
})),
},
"email": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
})),
},
}
Apparently the subfields first and last are not recognized as this is what I get when I run this mutation:
{
"data": null,
"errors": [
{
"message": "Variable \"$user\" got invalid value {\"email\":\"john#doe.com\",\"name\":{\"first\":\"john\",\"last\":\"doe\"}}.\nIn field \"name\": In field \"first\": Unknown field.\nIn field \"name\": In field \"last\": Unknown field.",
"locations": [
{
"line": 1,
"column": 21
}
]
}
]
}
Is this even possible?
EDIT: See comments in the accepted answer for the solution.
This are my first ever lines of Go but I will try to convey what I think the problem is.
First lets talk about the structure you want to be going for. I will use SDL here:
type Mutation {
createUser(user: CreateUser!): Boolean! # Maybe return user type here?
}
input CreateUser {
name: CreateUserName!
email: String!
}
input CreateUserName {
first: String!
last: String!
}
Okay now that we know that we need two input types lets get started!
var CreateUserName = graphql.NewInputObject(graphql.InputObjectConfig{
Name: "CreateUserName",
Fields: graphql.InputObjectConfigFieldMap{
"first": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
"last": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
})
var CreateUser = graphql.NewInputObject(graphql.InputObjectConfig{
Name: "CreateUser",
Fields: graphql.InputObjectConfigFieldMap{
"name": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(CreateUserName),
},
"email": &graphql.InputObjectFieldConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
})
Now all that should be left is adding the mutation field to your mutation object type.
I am in the middle of upgrading dredd from 1.08 to the latest version, while at it, I am trying to validate our api documentation, written in blueprint with the realtime test api and it is failing.
Since the tests are running against a real time api, the response returned from the api contains different values than specified in the blurprint document. I receive the following error from dredd.
Could someone help me figure it out ? :)
body: At '/data/email' No enum match for: "dredd_testzz#keyflow.se"
body: At '/data/firstName' No enum match for: "Sniper"
body: At '/data/lastName' No enum match for: "Wolf"
body: At '/data/verified' No enum match for: false
## `ResponseSchema` (object)
+ email: `john.doe#example.com` (string, required) - Email address
+ firstName: John (string, required) - First name
+ lastName: Doe (string, required) - Last name
+ verified: true (boolean, required) - True
# Group Account
## Login [/login/?]
Login user
### Login [POST]
Authentication required.
+ Request (application/json)
+ Attribute (LoginInputSchema)
+ Response 200 (application/json; charset=UTF-8)
+ Attribute
+ status: 200 (number, required, fixed)
+ data (ResponseSchema, required, fixed)
The JSON Schema generated by dredd is below
bodySchema: {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"status": {
"type": "number",
"enum": [
200
]
},
"data": {
"type": "object",
"properties": {
"email": {
"type": "string",
"enum": [
"john.doe#example.com"
],
"description": "Email address of the guest."
},
"firstName": {
"type": "string",
"enum": [
"John"
],
"description": "First name of the guest."
},
"lastName": {
"type": "string",
"enum": [
"Doe"
],
"description": "Last name of the guest."
},
"verified": {
"type": "boolean",
"enum": [
true
],
"description": "The user is verified or not"
},
},
"required": [
"email",
"firstName",
"lastName",
"verified",
],
"additionalProperties": false
}
},
"required": [
"status",
"data"
]
}
TL;DR: Try to use fixed-type instead of fixed in your API Blueprint document. fixed requires the sample values to be the actual values.
More elaborate explanation:
body: At '/data/email' No enum match for: "dredd_testzz#keyflow.se"
This means the response returned by the server under test contains a correctly parseable JSON body, but the body isn't valid according to the schema provided by the API description.
The error points to /data/email, which means the {"data": {"email": ... property is problematic. Further, it mentions that enum of values is expected, and that the actual response contains dredd_testzz#keyflow.se, which isn't allowed by the enum. The other errors are similar.
Looking at the API description, the specification of what is expected in the response goes as follows:
+ Attribute
+ status: 200 (number, required, fixed)
+ data (ResponseSchema, required, fixed)
The fixed attribute, as explained in the 4.3 Nested Member Types section of the MSON spec, fixes not only the structure, but also all values, and propagates further down the data structure:
...MAY specify fixed to indicate a "value object" where all the properties MUST be present and the values of the properties MUST be the values specified, if any, in its Nested Member Types. Further, such an object type structure MUST NOT contain any other properties.
I think you want to use fixed-type instead, which fixes just the structure. This is further explained also in the Making Dredd Validation Stricter section of the Dredd docs.
I have the next document:
{
id: 222,
email: user#user.com,
experiences: [
{
id: 3,
position: "Programmer",
description: "Programming things"
init_date: "1990-01-01",
end_date: "1999-05-11"
},
{
id: 4,
position: "Full Stack Developer",
description: "Programming things"
init_date: "1999-01-01",
end_date: "2008-05-11"
},
{
id: 7,
position: "Gardener",
description: "Taking care of flowers"
init_date: "2009-01-01",
end_date: "2015-05-11"
},
]
}
So, I would like to do the next filter: keyword: programming, experience years: > 3
The experience years should be the sum of the experiences that match the keyword.
Is it possible to do in only one query?
At the time of Indexing itself you add one extra field for experience, Instead of calculating with query. It will be faster easy to query also.
I am using jqgrid with multiplegroup option true for search. My filter looks like the following:
{"groupOp":"OR",
"rules":[{"field":"Total_case","op":"eq","data":"29"}],
"groups":[{"groupOp":"AND",
"rules":[{"field":"Total_case","op":"eq","data":"2"},{"field":"percent","op":"eq","data":"100"}],
"groups":[]}]}
I have rows with both total case = 2 ,percent = 100 and total case = 29. Since outer condition is "OR" condition, I am expecting two rows. However it displays no record. What is wrong?
The question seems be duplicate from answer your previous question. I just wrote the answer on your original question where I confirmed that it's a bug in the current version of jqGrid. As a workaround I suggested to modify requests having "groupOp":"OR" and both non-empty parts rules and groups so that the rules part will be inserted as new additional group inside of groups.
On the example which you posted one can first use jQuery.parseJSON to convert the JSON string postData.filters which you posted to the object form
{
groupOp: "OR",
rules: [
{field: "Total_case", op: "eq", data: "29"}
],
groups: [
{
groupOp: "AND",
rules: [
{field: "Total_case", op: "eq", data: "2"},
{field: "percent", op: "eq", data: "100"}
],
groups: []
}
]
}
Then one could test that groupOp is "OR" and both rules and groups are non-empty arrays. In the case one can move the rules part inside of groups. In other words one could convert it to the following object
{
groupOp: "OR",
rules: [],
groups: [
{
groupOp: "AND",
rules: [
{field: "Total_case", op: "eq", data: "2"},
{field: "percent", op: "eq", data: "100"}
],
groups: []
}
{
groupOp: "AND",
rules: [
{field: "Total_case", op: "eq", data: "29"}
],
groups: []
}
]
}
At the end one can use JSON.stringify to convert the object back to JSON string and assign the results back to postData.filters.
UPDATED: I posted the pull request which describe the changes which will do jqGrid internally during processing of the filtering/searching request.
The demo uses the fix and it seems that all works correctly now.