Using GraphQL-Shield with RedwoodJS

@thedavid Can I use GraphQL-Shield for authorization and other logics or does RedwoodJS provide any before/after hooks to run before functions/services? This is really important for us. Thanks

Hi @martineboh! Apologies for the super delayed reply here. Have you made any progress since writing this?

At this time, there are no specific hooks for this (that I’m aware of). The advance of the Redwood API is that you have access to each of the pieces directly regarding services, GraphQL SDL, and serverless functions. The only part being handled under the hood is the GQL resolvers.

After taking a quick look at GraphQL-Shield, it seems possible to handle this within serverless functions – for example, see api/src/functions/graphql.js. Regarding this snippet:

export const handler = createGraphQLHandler({
  getCurrentUser,
  schema: makeMergedSchema({
    schemas,
    services: makeServices({ services }),
  }),
  db,
})

I’m curious if you could add something there. Also, you might want to look into how makeMergedSchema() works under the hood.