File tree Expand file tree Collapse file tree 7 files changed +68
-20
lines changed Expand file tree Collapse file tree 7 files changed +68
-20
lines changed Original file line number Diff line number Diff line change
1
+ netlify /edge-functions /*
Original file line number Diff line number Diff line change 1
- {
2
- "imports" : {
3
- "netlify:edge" : " https://edge-bootstrap.netlify.app/v1/index.ts"
4
- }
5
- }
1
+ { "imports" : { "netlify:edge" : " https://edge.netlify.com/v1/index.ts" } }
Original file line number Diff line number Diff line change
1
+ import yoga from '../src'
2
+ import { createServer , Server } from 'http'
3
+ import { AddressInfo } from 'net'
4
+ import { fetch } from '@whatwg-node/fetch'
5
+
6
+ describe ( 'netlify-edge example integration' , ( ) => {
7
+ it ( 'should execute query' , async ( ) => {
8
+ const response = await yoga . fetch (
9
+ 'http://yoga/graphql?query=query{greetings}' ,
10
+ )
11
+ const body = await response . json ( )
12
+ expect ( body . errors ) . toBeUndefined ( )
13
+ expect ( body . data ) . toMatchInlineSnapshot ( `
14
+ {
15
+ "greetings": "This is the \`greetings\` field of the root \`Query\` type",
16
+ }
17
+ ` )
18
+ } )
19
+ } )
Original file line number Diff line number Diff line change
1
+ const { build } = require ( 'esbuild' )
2
+
3
+ async function main ( ) {
4
+ await build ( {
5
+ entryPoints : [ './src/index.ts' ] ,
6
+ outfile : 'netlify/edge-functions/graphql.js' ,
7
+ format : 'esm' ,
8
+ minify : false ,
9
+ bundle : true ,
10
+ platform : 'browser' ,
11
+ target : 'node14' ,
12
+ } )
13
+
14
+ console . info ( `Netlify Edge function build done!` )
15
+ }
16
+
17
+ main ( ) . catch ( ( e ) => {
18
+ console . error ( e )
19
+ process . exit ( 1 )
20
+ } )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
"private" : true ,
4
4
"version" : " 0.0.0" ,
5
5
"scripts" : {
6
- "start" : " netlify dev" ,
6
+ "start" : " yarn build && netlify dev" ,
7
+ "build" : " node ./build.js" ,
7
8
"check" : " exit 0"
8
9
},
9
10
"devDependencies" : {
10
- "netlify-cli" : " ^11.0.0"
11
+ "netlify-cli" : " ^11.0.0" ,
12
+ "esbuild" : " 0.15.9"
13
+ },
14
+ "dependencies" : {
15
+ "graphql-yoga" : " 3.0.0-next.3" ,
16
+ "graphql" : " 16.6.0"
11
17
}
12
18
}
Original file line number Diff line number Diff line change
1
+ import { createYoga , createSchema } from 'graphql-yoga'
2
+
3
+ const yoga = createYoga ( {
4
+ schema : createSchema ( {
5
+ typeDefs : /* GraphQL */ `
6
+ type Query {
7
+ greetings: String!
8
+ }
9
+ ` ,
10
+ resolvers : {
11
+ Query : {
12
+ greetings : ( ) =>
13
+ 'This is the `greetings` field of the root `Query` type' ,
14
+ } ,
15
+ } ,
16
+ } ) ,
17
+ } )
18
+
19
+ export default yoga
You can’t perform that action at this time.
0 commit comments