Skip to content

Commit

Permalink
removed code
Browse files Browse the repository at this point in the history
  • Loading branch information
paolini committed Jun 19, 2024
1 parent ff566ca commit 456b47c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
16 changes: 7 additions & 9 deletions app/graphql/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const resolvers = {
hello: () => 'world',
},
Mutation: {
post: async(_: any, {code, count}: any) => {
post: async(_: any, {count}: any, context: any) => {
const client = await clientPromise
console.log("mutation context:", context)
try {
await client.connect()
const account = client.db("coffee").collection("account")
const result = await account.insertOne({
code,
count,
timestamp: new Date()
})
Expand All @@ -34,7 +34,7 @@ const typeDefs = gql`
hello: String
}
type Mutation {
post(code: String!, count: Int!): String
post(count: Int!): String
}
`;

Expand All @@ -44,12 +44,10 @@ const server = new ApolloServer({
});

const handler = startServerAndCreateNextHandler(server, {
context: async (req, res) => ({ req, res, user: null }),
});
/*
startServerAndCreateNextHandler(server, {
context: async (req, res) => ({ req, res, user: await getLoggedInUser(req) }),
context: async (req, res) => {
console.log("context:", req, res)
return { req, res, user: null }
}
});
*/

export { handler as GET, handler as POST };
25 changes: 5 additions & 20 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,17 @@ function Auth() {
}

function CoffeeForm() {
const [code, setCode] = useState('12345')
const [count, setCount] = useState(1)

return <main>
<h1>dm-coffee</h1>
<form>
<div className="grid gap-6 mb-6 md:grid-cols-1">
<div>
<label
htmlFor="code"
className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
codice
</label>
<input
type="text"
id="code"
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="codice"
value={code}
onChange={e => setCode(e.target.value)}
required />
</div>
<div>
<label
htmlFor="count"
className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
numero
quanti caffé?
</label>
<select
id="count"
Expand Down Expand Up @@ -91,13 +75,14 @@ function CoffeeForm() {
</main>

async function submit(e: any) {
console.log("submitting", count)
e.preventDefault()
const query = `
mutation PostMutation($code: String!, $count: Int!) {
post(code: $code, count: $count)
mutation PostMutation($count: Int!) {
post(count: $count)
}`

const variables = { code, count }
const variables = { count }

const requestOptions = {
method: 'POST',
Expand Down
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

0 comments on commit 456b47c

Please sign in to comment.