Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

edgeql

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edgeql - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

1

dist/app.d.ts

@@ -14,2 +14,3 @@ /// <reference types="@cloudflare/workers-types" />

register(schema: string, resolve: GraphQLFieldResolver<any, any, any, any>): void;
register(schema: string, resolves: Record<string, GraphQLFieldResolver<any, any, any, any>>): void;
}

@@ -136,2 +136,20 @@ import { mergeSchemas } from '@graphql-tools/schema';

}
else if (args.length === 2 && typeof args[0] === 'string' && typeof args[1] === 'object') {
const s = buildSchema(args[0]);
const typs = ['Query', 'Mutuation', 'Subscription'];
for (const t of typs) {
const obj = s.getTypeMap()[t];
if (obj instanceof GraphQLObjectType) {
for (const f of Object.keys(obj.getFields())) {
if (args[1][f]) {
obj.getFields()[f].resolve = args[1][f];
}
else {
throw new Error(`no resolve function for ${obj.getFields()[f]}`);
}
}
}
}
this.schemas.push(s);
}
else {

@@ -138,0 +156,0 @@ throw new Error('invalid of parameters for register');

@@ -117,2 +117,77 @@ import { GraphQLObjectType, GraphQLString, GraphQLSchema } from 'graphql';

});
it('should work when schema string mulitiple query registered', async () => {
const app = new EdgeQL();
app.register(`
type Query {
hi: String
hello: String
ping: String
}
`, {
hello: () => 'world',
hi: () => 'world',
ping: () => 'pong',
});
let req = new Request('http://localhost', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: 'query H { hello }',
variables: {},
operationName: 'H',
extensions: {},
}),
});
let res = await app.fetch(req);
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
data: {
hello: 'world',
},
});
req = new Request('http://localhost', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: 'query H { hi }',
variables: {},
operationName: 'H',
extensions: {},
}),
});
res = await app.fetch(req);
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
data: {
hi: 'world',
},
});
req = new Request('http://localhost', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `query H {
hi
ping
}`,
variables: {},
operationName: 'H',
extensions: {},
}),
});
res = await app.fetch(req);
expect(res.status).toBe(200);
expect(await res.json()).toEqual({
data: {
hi: 'world',
ping: 'pong',
},
});
});
});

2

package.json
{
"name": "edgeql",
"version": "0.0.6",
"version": "0.0.7",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc