nileio / node-red-contrib-graphql-server

GraphQL and Subscription server implementation for Node-RED
MIT License
10 stars 1 forks source link

how to use it? #5

Closed limengsong closed 3 years ago

limengsong commented 3 years ago

Can you show how to use it? Currently copy the schema to the editor, after deployment, the service cannot be accessed

nileio commented 3 years ago

@limengsong You need to add a new GraphQL schema configuration. Use any GraphQL schema. I added an example which also include the GraphQL Pagination Specs (a little advanced), however,you can just create a very simple GraphQL schema containing a query and mutation. I will add more examples. Do you have the "Playground" enabled ? If enabled you should be able to access it using http://localhost:1880/graphql if you used the default path name /graphql please also check node help

limengsong commented 3 years ago

@nileio thank you for your reply。 Graphql is defined in the schema Not seen in the current configuration, define the relational library. Shouldn't it eventually be generated into the relational library?

limengsong commented 3 years ago

image image image

nileio commented 3 years ago

@limengsong your schema is not valid ! a valid GraphQL schema must include keyword schema to define valid operations. schema { query:Query } Type Query { Customer: Customer } for example You can find schema examples online or use the schema example bundled - I will add more simple examples. If you learning GraphQL, you can use the Visual Schema Editor, and it will help you to create a valid GraphQL schema visually.

Looking at your screen shot, it looks like you already enabled the Visual Schema Editor ! so you can click the edit button and it will open up the editor for you. define simple schema and copy the text in node-red schema field

limengsong commented 3 years ago

@nileio Thank you I now imported the example.json file and tried to run it. But still unsuccessful

nileio commented 3 years ago

@limengsong what exactly you mean by "unsuccessful"!? anyway just create your own simple schema from scratch and see if that works .. ignore the example for now as this is an advanced example which includes Pagination that I included and I need to fix it up. Will look into that later the example includes sqllite which need to point to the sqllite database location which is included in the example folder. a simple query such as query{ allcustomers{ totalCount } } should return the count of customer from the database. I will upload simple examples and remove the Pagination example for now.. it requires more work

nileio commented 3 years ago

updated example and added some instructions for usage.. more examples will be added in a later version