project-flogo/graphql

Error while parsing Graphql schema

LakshmiMekala opened this issue · 6 comments

Current behavior (how does the issue manifest):

Expected behavior:
Failed to create engine: error creating trigger instances - Error while parsing Graphql schema: Syntax Error GraphQL (1:2) Expected Name, found String "Query"
Minimal steps to reproduce the problem (not required if feature enhancement):
Create flogo app with below graphql schema :
"graphqlSchema": {
"Query": {
"Name": "Query",
"Fields": {
"address": {
"Type": "address",
"Args": {
"street": {
"Type": "graphql.String"
},
"number": {
"Type": "graphql.String"
}
}
}
}
}
}
Please tell us about your environment (Operating system, docker version, browser & web ui version, etc):

Flogo version (CLI & contrib/lib. If unknown, leave empty or state unknown): 0.X.X
flogo cli version v0.9.0-1-g1bc9a1b
Additional information you deem important (e.g. issue happens only occasionally):

@LakshmiMekala This is not correct GraphQL schema. It must adhere to specification.
Take a look at https://github.com/marmelab/GraphQL-example/blob/master/schema.graphql

@vijaynalawade It would be of great help if you can update the example json.

@vijaynalawade We tried passing content in 2 ways to graphql schema

  1. Content of https://github.com/marmelab/GraphQL-example/blob/master/schema.graphql to graphql schema as string
  2. Passing schema file to graphql schema as string .

For both the ways observed **Failed to create engine: error creating trigger instances - Error while parsing Graphql schema: Syntax Error **

@LakshmiMekala I updated the readme and sample applications #11. Can you please try again?
The schema which @vijaynalawade pointed to, will not work because it has "scalar" elements which are currently not supported in the current version of the graphql trigger. I will update the readme with all the limitations.

@cpramodroy can you update readme for example2.json..,
when i run mutation request: {"mutation":"mutation{ CreatePost(postObj:{title: "abc",body: "test123"}){ user{ name: "Sam" , userId: 1 } }}"}
response : {
"data": null,
"errors": [
{
"message": "Must provide an operation.",
"locations": []
}
]
}

@LakshmiMekala I am running my mutation requests from Postman. The mutation requests can be sent either as POST request or as a GET request.

As a POST request:

The POST request has two parts:

  1. Pre-request script
    image

  2. Body
    image

Output for above request:
image

As a GET Request:

Url: http://localhost:7879/graphql?query=mutation CreatePostMutation($post: PostInput) { CreatePost(post: $post) { postId title body}}&variables={"post": {"userId": 5, "title": "Sample Title", "body": "A quick white fox jumped over the lazy brown dog"}}

Output for above request:
image

For Get requests, we can also use www.graphqlbin.com that takes in a graphql server url (in our case http://localhost:7879/graphql) and provides a graphiql interface to execute queries. See example below:
image