graphql-cli-load
graphql-cli-load copied to clipboard
The "path" argument must be of type string
Hi,
When I run graphql load -m createShipRate --json rates.json
I get:
✖ The "path" argument must be of type string
Can you share more about your JSON format (an example) and your mutation?
Sure, here is what my JSON looks like:
[
{
"countryCode": "BH",
"countryName": "BAHRAIN",
"maxLength": 150,
"maxLWH": 300,
"maxWeight": 300,
"method": "EMS",
"minWeight": 0,
"rate": 1200,
"regionCode": 21
},
{
"countryCode": "BH",
"countryName": "BAHRAIN",
"maxLength": 150,
"maxLWH": 300,
"maxWeight": 500,
"method": "EMS",
"minWeight": 300,
"rate": 1500,
"regionCode": 21
},
{
"countryCode": "BH",
"countryName": "BAHRAIN",
"maxLength": 150,
"maxLWH": 300,
"maxWeight": 600,
"method": "EMS",
"minWeight": 500,
"rate": 1680,
"regionCode": 21
}
]
The schema that came back when I ran graphql get-schema looks like this:
input CreateShipRate {
countryCode: String!
countryName: String!
maxLength: Int!
maxLWH: Int!
maxWeight: Int!
method: String!
minWeight: Int!
rate: Int!
regionCode: Int!
}
And the mutations look like this:
type Mutation {
createShipRate(countryCode: String!, countryName: String!, maxLength: Int!, maxLWH: Int!, maxWeight: Int!, method: String!, minWeight: Int!, rate: Int!, regionCode: Int!): ShipRate
updateShipRate(countryCode: String, countryName: String, id: ID!, maxLength: Int, maxLWH: Int, maxWeight: Int, method: String, minWeight: Int, rate: Int, regionCode: Int): ShipRate
updateOrCreateShipRate(update: UpdateShipRate!, create: CreateShipRate!): ShipRate
deleteShipRate(id: ID!): ShipRate
}
This looks good to me.
What graphql-api is your backend running? The schema should be a bit more complete, it misses ShipRate, and the query types.
I'm using Graphcool.
The schema is more complete. It includes the query types and the ShipRate type. It was just a lot to include here and from what I can tell it looks correct.
Ok thanks I'll investigate. All the other graphql cli operations and plugins work without issues?
Ok, I did two fixes, can you update from npm and try again.
- also handle endpoints that are stored as string
- handle object-type returns from mutations
load -m createShipRate --json rates.json
Using endpoint default: {"url":"https://api.graph.cool/simple/v1/cj2chjbncvq730104upuyxxx"}
Using mutation "createShipRate": "".
Done parsing JSON-file /Users/mh/trash/shiprate/rates.json rows: 3
Sending query:
mutation {
_0 : createShipRate ( countryCode: "BH",countryName: "BAHRAIN",maxLength: 150,maxLWH: 300,maxWeight: 300,method: "EMS",minWeight: 0,rate: 1200,regionCode: 21 ) { id }
_1 : createShipRate (...
✔ Call succeeded:
{"_0":{"id":"cjd0stgct574n0107e687zbci"},"_1":{"id":"cjd0stgd9574p0107yx8zhjhi"},"_2":{"id":"cjd0stgdn574r0107w2feufml"}}...
I updated, but I'm still getting the same error.
can you share your .graphqlconfig? Fee free to redact the URL I just need the structure.
How di you update ?
Hi @jexp I'm also facing this issue, I've tried with multiple configs, here is the last .graphqlconfig I used :
"projects": {
"Sports": {
"schemaPath": "./schema.graphql",
"extensions": {
"endpoints": {
"local": "http://localhost/graphql"
},
"load": {
"csv": "clubs.csv",
"mutation": "newUser",
"mapping": {"pseudo": "Pseudo", "password": "Password", "email": "Email", "profileType": "ProfileType", "sex": "Gender"}
}
}
}
}
}
Using graphql load -e local or the full command still return 'Path must be a string. Received undefined'.
Do you have any update on this issue ?
After investigating a bit, I think this is because I was using [email protected] and your package depends on ^1.0.0-beta.4 version.
Currently trying it
Can't see a 4.2.0 release here: https://github.com/graphql-cli/graphql-cli/releases ?
Sorry, I meant the last version