Hi, im trying to run a query from a resolver funct...
# prisma-whats-new
b
Hi, im trying to run a query from a resolver function but its not retuning any data. Anyone know what im missing?
a
What do you mean by 'not returning any data'? Does it return an error? Does it return
null
? What does the SDL look like for your resolver function? It's best to create a post on the Forum with this additional information.
b
The output in the logs in playground is this: data: {}
If i run the query in the playground then I get the data returned so I think the query is correct
just cant figure out why it doesnt work in the function
the schema is just this:
type basicFunctionPayload { title: String! } extend type Query { basicFunction: basicFunctionPayload }
super simple
the yml file contains this:
basicFunction: type: resolver schema: src/basicFunction.graphql handler: code: src/basicFunction.js
a
Can you run
graphcool logs
and check the full logs?
b
sure can i limit to just that function somehow?
a
-f basicFunction
b
thank you
So it seems I do have an error
"logs": [ { "2017-11-12T131230.131Z": "{\"errorMessage\":\"{\\\"response\\\":{\\\"error\\\":\\\"Syntax error while parsing GraphQL query. Invalid input 'P', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 2, column 7):\\\\n Page(id: \\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\") {\\\\n ^\\\",\\\"status\\\":200},\\\"request\\\":{\\\"query\\\":\\\"\\\\n Page(id: \\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\") {\\\\n title\\\\n }\\\"},\\\"name\\\":\\\"Error\\\",\\\"message\\\":\\\"GraphQL Error (Code: 200): {\\\\\\\"response\\\\\\\":{\\\\\\\"error\\\\\\\":\\\\\\\"Syntax error while parsing GraphQL query. Invalid input 'P', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 2, column 7):\\\\\\\\n Page(id: \\\\\\\\\\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\\\\\\\\\") {\\\\\\\\n ^\\\\\\\",\\\\\\\"status\\\\\\\":200},\\\\\\\"request\\\\\\\":{\\\\\\\"query\\\\\\\":\\\\\\\"\\\\\\\\n Page(id: \\\\\\\\\\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\\\\\\\\\") {\\\\\\\\n title\\\\\\\\n }\\\\\\\"}}\\\",\\\"stack\\\":\\\"Error: GraphQL Error (Code: 200): {\\\\\\\"response\\\\\\\":{\\\\\\\"error\\\\\\\":\\\\\\\"Syntax error while parsing GraphQL query. Invalid input 'P', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 2, column 7):\\\\\\\\n Page(id: \\\\\\\\\\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\\\\\\\\\") {\\\\\\\\n ^\\\\\\\",\\\\\\\"status\\\\\\\":200},\\\\\\\"request\\\\\\\":{\\\\\\\"query\\\\\\\":\\\\\\\"\\\\\\\\n Page(id: \\\\\\\\\\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\\\\\\\\\") {\\\\\\\\n title\\\\\\\\n }\\\\\\\"}}\\\\n at GraphQLClient.<anonymous> (/var/task/node_modules/graphql-request/dist/src/index.js8735)\\\\n at step (/var/task/node_modules/graphql-request/dist/src/index.js4023)\\\\n at Object.next (/var/task/node_modules/graphql-request/dist/src/index.js2153)\\\\n at fulfilled (/var/task/node_modules/graphql-request/dist/src/index.js1258)\\\\n at process._tickDomainCallback (internal/process/next_tick.js1357)\\\"}\"}" } ], "returnValue": { "errorMessage": "{\"response\":{\"error\":\"Syntax error while parsing GraphQL query. Invalid input 'P', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 2, column 7):\\n Page(id: \\\"cj9tp9ahgfxe40112nvdpec68\\\") {\\n ^\",\"status\":200},\"request\":{\"query\":\"\\n Page(id: \\\"cj9tp9ahgfxe40112nvdpec68\\\") {\\n title\\n }\"},\"name\":\"Error\",\"message\":\"GraphQL Error (Code: 200): {\\\"response\\\":{\\\"error\\\":\\\"Syntax error while parsing GraphQL query. Invalid input 'P', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 2, column 7):\\\\n Page(id: \\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\") {\\\\n ^\\\",\\\"status\\\":200},\\\"request\\\":{\\\"query\\\":\\\"\\\\n Page(id: \\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\") {\\\\n title\\\\n }\\\"}}\",\"stack\":\"Error: GraphQL Error (Code: 200): {\\\"response\\\":{\\\"error\\\":\\\"Syntax error while parsing GraphQL query. Invalid input 'P', expected OperationDefinition, FragmentDefinition or TypeSystemDefinition (line 2, column 7):\\\\n Page(id: \\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\") {\\\\n ^\\\",\\\"status\\\":200},\\\"request\\\":{\\\"query\\\":\\\"\\\\n Page(id: \\\\\\\"cj9tp9ahgfxe40112nvdpec68\\\\\\\") {\\\\n title\\\\n }\\\"}}\\n at GraphQLClient.<anonymous> (/var/task/node_modules/graphql-request/dist/src/index.js8735)\\n at step (/var/task/node_modules/graphql-request/dist/src/index.js4023)\\n at Object.next (/var/task/node_modules/graphql-request/dist/src/index.js2153)\\n at fulfilled (/var/task/node_modules/graphql-request/dist/src/index.js1258)\\n at process._tickDomainCallback (internal/process/next_tick.js1357)\"}" } }
Cant see a 'P' anywhere though lol
a
P as in the first letter of
Page
I can reproduce your error
Very strange indeed
Let me check
Actually, not so strange
The query is not valid
You say the query works in the Playground, but it's not the same as in your code. You need to wrap it in either
query {...}
or just
{ ... }
Copy code
const Res = await client.request(`
  {
    Page(id: "cj9wuwyvh004d0116fjeu7mrr") {
      title
    }
  }`)
Or:
Copy code
const Res = await client.request(`
  query {
    Page(id: "cj9wuwyvh004d0116fjeu7mrr") {
      title
    }
  }`)
b
Thank you, yes my query was wrong, still getting to grips with this 🙂