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

Mutation doesn't work but Query does [5:35pm] #29

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: take a working graphQL query and implement it as a graphQL mutation

error: Screen Shot 2023-07-12 at 6 12 02 PM

proposed approach: when creating this app as a react-express app, there were no graphQL "mutations" but the app did mutate postgreSQL data and basically do graphQL mutations but within graphQL query resolvers()

frankcollins3 commented 1 year ago

problem: type Mutation { } was already added to graphql/schema.ts

solution: graphql/resolvers.ts: Mutation: {

[6:53pm]

frankcollins3 commented 1 year ago

don't have to reopen but forgot the UsersType: addUser( id: Int! google_id: String! icon: String! username: String! email: String! password: String! age: Int! ): Users }

[6:55pm]

frankcollins3 commented 1 year ago

next error in the process: Screen Shot 2023-07-12 at 6 54 35 PM

    mutation {
      addUser(
        id: 4,
        google_id: "no google-id", 
        icon: "/water_img/panda.png",
        username: "lavaplace",
        password: "lavaPassword123", 
        **email:  lavaplace@gmail.com,**        // email had no quotes and all of these strings had single quotes not double
        age: 30
      ) {
        id, google_id, icon, username, email, password, age
      }
    }

this works. It was either the email having no quotes or every other string key having single quotes only.

[6:56pm]