Skip to content

Possible to cache graphql.parse() results? #5377

Open
@edulop91

Description

@edulop91

Short description

I am wondering if there is an easy way to cache the graphql schema AST that is generated by graphql.parse function call. I have been working on integrating OPA for our graphql layer and, unfortunately, am running into performance issues due how long it takes to generate the AST from a raw query.

Our graphQL schema does not change between each authorization decisions and therefore it makes sense to generate thes chema AST once and re-use it for each authorization query.

I am running OPA embedded into Go mode. This is running locally from my laptop.

Steps To Reproduce

Nothing really interesting here. Rego looks like:

package graphql

import future.keywords

query_ast := graphql.parse(input.query, input.schema)[0]

The only difference is having farily large input.query and input.schema.

Expected behavior

I would like to find a way to cache my graphql schema AST between authorization decisions.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions