aaronwlee / oak-graphql

A simple graphql middleware for oak deno framework.
Other
121 stars 23 forks source link

Variables aren't picked up when calling from frontend #10

Closed autsada closed 4 years ago

autsada commented 4 years ago

Hi

I finished making the API, it works well in the playground and now I connected this API to the frontend. The queries that don't require variables work, but the queries and mutations that require variables don't work.

I have tested both with my next.js frontend and postman.

Here are screenshots from using postman. Screenshot (25) Screenshot (26)

aaronwlee commented 4 years ago

Hi @autsada right_solution Here is the right solution and you can find more information here.

aaronwlee commented 4 years ago

Also, it might be easier to use apollo for the client-side part.

autsada commented 4 years ago

Hi arronwlee,

Thank you for your quick reply. Actually I used apollo on the frontend, and I have defined my query on the frontend same way as your example. Here is my code.

query ME($userId: String!) {
    me(userId: $userId) {
      id
      username
      email
      roles
      created_at
    }
  }

I think it is not because of the frontend, which I also have tested the same code with my other Graphql API made in Node.js and it works fine.

I have tested your example code using a variable in the playground, it works when I enter the argument directly, but it doesn't when I put it as a variable. Please see the screenshots below.

Screenshot (29) Screenshot (30)

aaronwlee commented 4 years ago

as far as mine is working fine result

I think you're using the wrong version... can you try to reload the module or use the 0.2 version? https://deno.land/x/oak_graphql@0.2/mod.ts

let me know if you got the same error after reloading it. I can make a new version branch for you.

autsada commented 4 years ago

Yes, that may cause the problem. I will test it and will update you soonest.

Thank for your help :)

autsada commented 4 years ago

Hi @aaronwlee

Yes, the wrong version was indeed cause a problem. Now it works.

Thank you very much for your time.