Title
p

peter

02/06/2018, 7:48 PM
are there any examples that show how to integrate a prisma service with something like a 3rd party API? I am trying to figure out how to build a web scraping application that handles events (new scrape requests) and responds with GraphQL mutations/queries
h

huv1k

02/06/2018, 7:51 PM
Or in application server you can call 3rd party apis in resolvers
But i can see server side subscription what will push webook with URL to scrape and after you scrape it you can make graphql request to your app server with results for example
But hard to say, because idk if you want to use some service to scrape or build your own scrapper etc
p

peter

02/06/2018, 7:54 PM
i am building my own scraper that runs on node
and would rather not setup my own webhook service
h

huv1k

02/06/2018, 7:56 PM
so make node server for scrapping and you can send url to scrape in resolver for example
👍 1
p

peter

02/06/2018, 7:57 PM
and just treat it as if im calling a typical HTTP api?
h

huv1k

02/06/2018, 7:57 PM
yea
p

peter

02/06/2018, 7:57 PM
ok that makes sense and sounds like a clean solution
thanks!
h

huv1k

02/06/2018, 7:58 PM
no problem 🙂
p

peter

02/06/2018, 7:58 PM
are there any samples that show resolvers like that?
h

huv1k

02/06/2018, 7:59 PM
i have something not finished for instagram api
export const instagramMutation = {
  async upsertInstagram(parent, { id = "", accessToken, name, instagramId }, ctx: Context, info) {
    const data = {
      accessToken,
      name,
      instagramId
    }

    const FB = new Facebook({})

    FB.setAccessToken(accessToken)


    FB.api(`${instagramId}/media`, 'post', res => {
      console.log(res)
    })

    return await ctx.db.mutation.upsertInstagram(
      {
        where: {
          id
        },
        create: {
          ...data
        },
        update: {
          ...data
        }
      },
      info
    )
  }
}
but you can get feel how to do it
p

peter

02/06/2018, 7:59 PM
beautiful! that is very useful. thanks again 🙂
h

huv1k

02/06/2018, 8:00 PM
but sometimes i would rather scrape instagram then call their API 😄
👍 1