Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A graphql-cli data import plugin to call mutations with data from JSON/CSV files

License

NotificationsYou must be signed in to change notification settings

neo4j-graphql/graphql-cli-load

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data import plugin for graphql-cli.

Installation

npm i -g graphql-cli graphql-cli-load

Configuration

Configure the plugin via the.graphqlconfig or command line.

The schema will be obtained from theschemaPath key, you can fetch it viagraphql get-schema

All other options such ascsv,json,mutation ormappingcan be placed in theextensions.load keyor provided via commandline.

Here is an example:

.graphqlconfig

{"schemaPath":"schema.graphql","includes": ["src/**/*.graphql","src/**/*.gql",  ],"extensions": {"load": {// this section is optional"csv" :"reviews.txt","mutation":"createReview","mapping": {"text" :"review","rating" :"stars"}    }  }}

Usage

You can now run:

graphql load

or

graphql load --csv reviews.txt --mutation createReview2 --mapping '{ "text" : "commentary", "rating" : "stars"}'Using endpoint starwars: http://localhost:7474/graphql/Using mutation "createReview2".Done parsing CSV-file /Users/mh/d/js/graphql-cli-load/example/reviews.txt rows: 3 meta: {"delimiter":"\t","linebreak":"\n","aborted":false,"truncated":false,"cursor":566,"fields":["episode","text","rating"]}Using mapping: {"text":"commentary","rating":"stars"}Sending query:mutation { _0 : createReview2 ( episode: NEWHOPE,commentary: "A legendarily expansive and ambitious start to the sci-fi saga, George Lucas opened our eyes to the possibilities of blockbuster filmmaki...✔ Call succeeded:{"_0":"Nodes created: 1\nProperties set: 3\nLabels added: 1\n","_1":"Nodes created: 1\nProperties set: 3\nLabels added: 1\n","_2":"Nodes created: 1\nProperties set: 3\nLabels added: 1\n"}...

Options

/usr/local/bin/graphql load [--json] [--csv] [--endpoint] [--mutation] [--mapping] [--delim]Optionen:  --help          Hilfe anzeigen                                       [boolean]  --mapping, -p   name mapping of input to mutation (json)  --mutation, -m  mutation to call  --endpoint, -e  endpoint name to use  --json, -j      json file to load  --csv, -c       csv file to load  --delim, -d     delimiter for arrays

Which will take each line of thecsv orjson file and call themutation on theendpoint with the data (optionallymapping columns).Non-absolute files are resolved relative to the directory containing.graphqlconfig.

Test with Neo4j-GraphQL Extension

To test this with the neo4j-graphql extension:

  1. npm install -g neo4j-graphql-cli
  2. git clone https://github.com/neo4j-graphql/graphql-cli-load && cd example
  3. neo4j-graphql example-schema.graphql (remember the auth header)
  4. npm install -g graphql-cli graphql-cli-load
  5. Rungraphql to install the endpoint, andmanually add the auth-header to.graphqlconfig, like here:
"endpoints": {  "starwars": {"url":"http://localhost:7474/graphql/","headers":{"Authorization": "Basic bmVvNGo6dGVzdA=="}}},
  1. Rungraphql load --csv reviews.txt orgraphql load --csv reviews.json

About

A graphql-cli data import plugin to call mutations with data from JSON/CSV files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp