graphql-cli-load icon indicating copy to clipboard operation
graphql-cli-load copied to clipboard

The "path" argument must be of type string

Open jharmon141 opened this issue 7 years ago • 13 comments

Hi,

When I run graphql load -m createShipRate --json rates.json

I get:

✖ The "path" argument must be of type string

jharmon141 avatar Jan 28 '18 00:01 jharmon141

Can you share more about your JSON format (an example) and your mutation?

jexp avatar Jan 28 '18 12:01 jexp

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
}

jharmon141 avatar Jan 28 '18 15:01 jharmon141

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.

jexp avatar Jan 28 '18 18:01 jexp

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.

jharmon141 avatar Jan 28 '18 18:01 jharmon141

Ok thanks I'll investigate. All the other graphql cli operations and plugins work without issues?

jexp avatar Jan 28 '18 19:01 jexp

Ok, I did two fixes, can you update from npm and try again.

  1. also handle endpoints that are stored as string
  2. 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"}}...

jexp avatar Jan 29 '18 23:01 jexp

I updated, but I'm still getting the same error.

jharmon141 avatar Jan 31 '18 00:01 jharmon141

can you share your .graphqlconfig? Fee free to redact the URL I just need the structure.

jexp avatar Jan 31 '18 03:01 jexp

How di you update ?

jexp avatar Jan 31 '18 03:01 jexp

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 ?

NicolasSmit avatar Feb 08 '18 15:02 NicolasSmit

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

NicolasSmit avatar Feb 08 '18 16:02 NicolasSmit

Can't see a 4.2.0 release here: https://github.com/graphql-cli/graphql-cli/releases ?

jexp avatar Feb 08 '18 23:02 jexp

Sorry, I meant the last version

NicolasSmit avatar Feb 09 '18 11:02 NicolasSmit