@@ -25,14 +25,12 @@ npm i prom-client @graphql-yoga/plugin-prometheus
25
25
You can then add the plugin to your GraphQL server:
26
26
27
27
``` ts
28
- import { execute , parse , specifiedRules , subscribe , validate } from ' graphql'
29
- import { envelop , useEngine } from ' @envelop/core'
30
- import { usePrometheus } from ' @envelop/prometheus'
28
+ import { createYoga } from ' graphql-yoga'
29
+ import { usePrometheus } from ' @graphql-yoga/plugin-prometheus'
31
30
32
- const getEnveloped = envelop ({
31
+ const yoga = createYoga ({
33
32
plugins: [
34
- useEngine ({ parse , validate , specifiedRules , execute , subscribe }),
35
- // ... other plugins ...
33
+ schema : mySchema , // Provide your GraphQL schema
36
34
usePrometheus ({
37
35
endpoint: ' /metrics' , // optional, default is `/metrics`, you can disable it by setting it to `false` if registry is configured in "push" mode
38
36
// Optional, see default values below
@@ -58,6 +56,11 @@ const getEnveloped = envelop({
58
56
})
59
57
]
60
58
})
59
+
60
+ const server = createServer (yoga )
61
+ server .listen (4000 , () => {
62
+ console .log (` Server is running on http://localhost:4000/${server .graphqlEndpoint } ` )
63
+ })
61
64
```
62
65
63
66
<Callout type = " warning" >
0 commit comments