9.1.3 • Published 8 months ago

@envelop/graphql-jit v9.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@envelop/graphql-jit

This plugins replaces the original execute of GraphQL with graphql-jit.

Getting Started

yarn add @envelop/graphql-jit

Usage Example

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useGraphQlJit } from '@envelop/graphql-jit'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useGraphQlJit(
      {
        // your compiler options here. See https://github.com/zalando-incubator/graphql-jit#compiledquery--compilequeryschema-document-operationname-compileroptions
      },
      {
        onError: (e: Error) => {} // custom error handler
      }
    )
  ]
})

Conditional Execution

If you wish to conditionally use the JIT executor based on the incoming request, you can use enableIf config flag and return a boolean based on the ExecutionArgs:

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useGraphQlJit } from '@envelop/graphql-jit'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useGraphQlJit(
      {
        // your compiler options here. See https://github.com/zalando-incubator/graphql-jit#compiledquery--compilequeryschema-document-operationname-compileroptions
      },
      {
        enableIf: executionArgs => executionArgs.contextValue.shouldUseJit
      }
    )
  ]
})

## Configuring JIT cache

You can configure the JIT cache with the following options:

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useGraphQlJit } from '@envelop/graphql-jit'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useGraphQlJit(
      {
        // your compiler options here
      },
      {
        cache: lru() // Pass in a custom cache instance, by default a new LRU cache is created which uses the default `max` and `ttl` settings
      }
    )
  ]
})

Notes

You can find more details here: https://github.com/zalando-incubator/graphql-jit

9.0.1

8 months ago

9.0.0

8 months ago

7.0.0

2 years ago

6.0.3

2 years ago

6.0.2

2 years ago

6.0.5

2 years ago

6.0.4

2 years ago

8.0.4

11 months ago

8.0.1

2 years ago

8.0.0

2 years ago

8.0.3

2 years ago

8.0.2

2 years ago

9.1.3

8 months ago

9.1.2

8 months ago

9.1.1

8 months ago

9.1.0

8 months ago

6.0.1

2 years ago

6.0.0

2 years ago

5.0.6

3 years ago

5.0.5

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.4.1

3 years ago

4.4.0

3 years ago

4.4.2

3 years ago

4.3.0

3 years ago

4.6.0

3 years ago

4.5.0

3 years ago

4.2.3

3 years ago

4.2.2

3 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.0.0

4 years ago

4.1.0

4 years ago

2.0.0

4 years ago

3.0.0

4 years ago

3.1.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago