#Apollo client with next js

16 messages · Page 1 of 1 (latest)

tiny willow
#

Hi, i've tried for severals hours to implement apollo client to my next js app, does anyone has any ideea on how could i do it? ( my apollo backend runs on an express server )

#

So basically i have a form, where user enters his information ( register info ) and the information should be queried, but i have no ideea how to do it... ( i've thinked about using server actions, but they are unstable )

#

const client = new ApolloClient({
    uri:"http://localhost:4000/graphql",
    cache:new InMemoryCache()
})

export default client```
#

i am using next js 13.4

uncut granite
#

Well, then you can call this in your file:

const { data } = await client.query({
      query: gql`
        query Countries {
          countries {
            code
            name
            emoji
          }
        }
      `,
    });

Is that what you need to know?

tiny willow
#

and use the onclick method to send it

#

i can't use client.query cause it is

#

a server thing ig

uncut granite
#

Does it gives your some error or?

tiny willow
#

lemme try again

uncut granite
#

I would say there should be no problem with that

tiny willow
#

ok, you are right

#

it works

#

ty

uncut granite
#

yep ❤️