Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@giraphql/plugin-sub-graph
Advanced tools
A GiraphQL plugin for creating multiple variants or sub-selections of the same graph
A plugin for creating sub-selections of your graph. This Allows you to use the same code/types for multiple variants of your API.
One common use case for this is to share implementations between your public and internal APIs, by only exposing a subset of your graph publicly.
yarn add @giraphql/plugin-sub-graph
import SubGraphPlugin from '@giraphql/plugin-sub-graph';
const builder = new SchemaBuilder<{
SubGraphs: 'Public' | 'Internal';
}>({
plugins: [SubGraphPlugin],
subGraphs: {
defaultsForTypes: [],
inheritFieldGraphsFromType: true,
},
});
//in another file:
const schema = builder.toSchema({});
const publicSchema = builder.toSchema({ subGraph: 'Public' });
const internalSchema = builder.toSchema({ subGraph: 'Internal' });
// You can also build a graph using multiple subgraphs:
const combinedSchema = builder.toSchema({ subGraph: ['Internal', 'Public'] });
subGraphs
: An optional array of sub-graph the type should be included in.defaultSubGraphsForFields
: Default sub-graph for fields of the type to be included in.subGraphs
: An optional array of sub-graph the field to be included in. If not provided, will
fallback to:
defaultSubGraphsForFields
if set on typesubGraphs
of the type if subGraphs.fieldsInheritFromTypes
was set in the buildersubGraphs.defaultForTypes
: Specifies what sub-graph a type is part of by default.
subGraphs.fieldsInheritFromTypes
: defaults to false
. When true, fields on a type will default
to being part of the same sub-graph as their parent type. Only applies when type does not have
defaultSubGraphsForFields
set.
You can mock any field by adding a mock in the options passed to builder.buildSchema
under
mocks.{typeName}.{fieldName}
.
builder.queryType({
// Query type will be available in default, Public, and Internal schemas
subGraphs: ['Public', 'Internal'],
// Fields on the Query object will now default to not being a part of any subgraph
defaultSubGraphsForFields: [];
fields: (t) => ({
someField: t.string({
// someField will be in the default schema and "Internal" sub graph, but
// not present in the Public sub graph
subGraphs: ['Internal']
resolve: () => {
throw new Error('Not implemented');
},
}),
}),
});
When creating a sub-graph, the plugin will only copy in types that are included in the sub-graph, either by explicitly setting it on the type, or because the sub-graph is included in the default list. Like types, output fields that are not included in a sub-graph will also be omitted. Arguments and fields on Input types can not be removed because that would break assumptions about arguments types in resolves.
If a type that is not included in the sub-graph is referenced by another part of the graph that is included in the graph, a runtime error will be thrown when the sub graph is constructed. This can happen in a number of cases including cases where a removed type is used in the interfaces of an object, a member of a union, or the type of an field argument.
FAQs
A GiraphQL plugin for creating multiple variants or sub-selections of the same graph
We found that @giraphql/plugin-sub-graph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.