graphile-build
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.5
{ | ||
"name": "graphile-build", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.5", | ||
"description": "Build a GraphQL schema from plugins", | ||
@@ -32,3 +32,3 @@ "main": "node8plus/index.js", | ||
"debug": ">=2 <3", | ||
"graphql-parse-resolve-info": "4.0.0-alpha.1" | ||
"graphql-parse-resolve-info": "4.0.0-alpha.5" | ||
}, | ||
@@ -35,0 +35,0 @@ "engines": { |
@@ -1,3 +0,2 @@ | ||
graphile-build | ||
============== | ||
# graphile-build | ||
@@ -11,4 +10,4 @@ graphile-build provides you with a framework to build high-performance | ||
An example of an application built on `graphile-build` is [PostGraphQL | ||
v4+](https://github.com/postgraphql/postgraphql) which allows you to run just | ||
An example of an application built on `graphile-build` is [PostGraphile | ||
v4+](https://github.com/graphile/postgraphile) which allows you to run just | ||
one command to instantly get a fully working and secure GraphQL API up and | ||
@@ -23,4 +22,3 @@ running based on your PostgreSQL database schema. | ||
Usage | ||
----- | ||
## Usage | ||
@@ -48,4 +46,4 @@ The following [runnable example][] creates a plugin that hooks the | ||
sides: { | ||
type: GraphQLInt, | ||
}, | ||
type: GraphQLInt | ||
} | ||
}, | ||
@@ -57,4 +55,4 @@ resolve(_, { sides = myDefaultMax }) { | ||
); | ||
}, | ||
}, | ||
} | ||
} | ||
}); | ||
@@ -74,7 +72,16 @@ } | ||
myDefaultMin: 1, | ||
myDefaultMax: 6, | ||
myDefaultMax: 6 | ||
}); | ||
// Run our query | ||
const result = await graphql(schema, `query { random }`, null, {}); | ||
const result = await graphql( | ||
schema, | ||
` | ||
query { | ||
random | ||
} | ||
`, | ||
null, | ||
{} | ||
); | ||
console.log(result); // { data: { random: 4 } } | ||
@@ -87,7 +94,5 @@ })().catch(e => { | ||
Plugins | ||
------- | ||
## Plugins | ||
Plugins can be asynchronous functions (simply define them as `async function | ||
MyPlugin(builder, options) {...}` or return a Promise object). | ||
Plugins can be asynchronous functions (simply define them as `async function MyPlugin(builder, options) {...}` or return a Promise object). | ||
@@ -102,23 +107,19 @@ When a plugin first runs, it should do any of its asynchronous work, and then | ||
function MyRandomPlugin(builder) { | ||
builder.hook('HOOK_NAME_HERE', | ||
( | ||
// 'inputValue' - the value to replace with the return result | ||
inputValue, | ||
// 'build' - a frozen collection of utils and stores for this build, | ||
// not available during the 'build' event | ||
{ extend, /* ... */ }, | ||
// 'context' - more information about the current object | ||
{ scope: { isMyRandomObject, /* ... */ }, /* ... */ }, | ||
) => { | ||
if (!isMyRandomObject) { | ||
// Exit early if this doesn't have the scope we want | ||
return inputValue; | ||
} | ||
return extend(inputValue, { | ||
// add additional attributes here... | ||
}); | ||
builder.hook("HOOK_NAME_HERE", ( | ||
// 'inputValue' - the value to replace with the return result | ||
inputValue, | ||
// 'build' - a frozen collection of utils and stores for this build, | ||
// not available during the 'build' event | ||
{ extend /* ... */ }, | ||
// 'context' - more information about the current object | ||
{ scope: { isMyRandomObject /* ... */ } /* ... */ } | ||
) => { | ||
if (!isMyRandomObject) { | ||
// Exit early if this doesn't have the scope we want | ||
return inputValue; | ||
} | ||
); | ||
return extend(inputValue, { | ||
// add additional attributes here... | ||
}); | ||
}); | ||
} | ||
@@ -125,0 +126,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122
215054
+ Addedgraphql-parse-resolve-info@4.0.0-alpha.5(transitive)
- Removedgraphql-parse-resolve-info@4.0.0-alpha.1(transitive)