frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

working graphQL but not as exported func with return statement of same query [9:51am] #64

Closed frankcollins3 closed 11 months ago

frankcollins3 commented 11 months ago

attempting to do: take a working graphQL query and modularize it by: declaring it elsewhere in a func that takes the same {user & password} endpoints as params populates those into the query with string interpolation

error: Expected name, found @ Screen Shot 2023-07-18 at 9 47 37 AM

Screen Shot 2023-07-18 at 9 47 16 AM

browser logs: Screen Shot 2023-07-18 at 9 48 59 AM

proposed approach: 0: walk things back to an abstract definition of the params.

1: .log() the query and find discrepancy

frankcollins3 commented 11 months ago

const returnLoginQuery = userLoginQueryStringFunc("tonyhawk@gmail.com", "birdman900"):

   query {
         userLogin(email: tonyhawk@gmail.com, password: birdman900 ) {      
           username,
           password,
           email,
           age,
           icon,
           token          
         }
       }

hand written query:

           body: JSON.stringify({
             query: `
               query {
                 userLogin(email: "tonyhawk@gmail.com", password: "birdman900" ) {      
                   username,
                   password,
                   email,
                   age,
                   icon,
                   token          
                 }
               }
             `,
           }),
         })

[9:55am]

frankcollins3 commented 11 months ago

👎 query: query { ${returnLoginQuery} } , [9:59pm]

frankcollins3 commented 11 months ago

chatGPT pitched a hand they have to be wrapped in double quotes [10:07am]