New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-component

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-component - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### v1.1.1
- [BREAKING (sorry, but it is 5 minutes later)]: data sources appear by constructor name on context
### v1.1.0

@@ -2,0 +6,0 @@

9

lib/datasource.js

@@ -32,4 +32,4 @@ 'use strict';

for (const override of dataSourceOverrides) {
debug(`overriding datasource ${override.name}`);
dataSources[override.name] = intercept(override, context);
debug(`overriding datasource ${override.constructor.name}`);
dataSources[override.constructor.name] = intercept(override, context);
}

@@ -39,4 +39,5 @@

for (const dataSource of component.dataSources) {
if (!dataSources[dataSource.name]) {
dataSources[dataSource.name] = intercept(dataSource, context);
const name = dataSource.constructor.name;
if (!dataSources[name]) {
dataSources[name] = intercept(dataSource, context);
}

@@ -43,0 +44,0 @@ }

@@ -32,13 +32,2 @@ 'use strict';

for (const dataSource of dataSources) {
if (!dataSource.name) {
throw new Error(`dataSource ${dataSource.constructor.name} must have a name field`);
}
}
for (const override of dataSourceOverrides) {
if (!override.name) {
throw new Error(`dataSource ${override.constructor.name} must have a name field`);
}
}
//This is really only used for avoiding directive collisions

@@ -45,0 +34,0 @@ this._id = cuid().slice(12);

{
"name": "graphql-component",
"version": "1.1.0",
"version": "1.1.1",
"description": "Build graphql schema with components",

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

@@ -142,5 +142,2 @@ [![Build Status](https://dev.azure.com/tlivings0149/Trevor%20Livingston/_apis/build/status/tlivings.graphql-component?branchName=master)](https://dev.azure.com/tlivings0149/Trevor%20Livingston/_build/latest?definitionId=1&branchName=master)

class PropertyDataSource {
get name() {
return 'PropertyDataSource';
}
async getPropertyById(context, id) {

@@ -173,2 +170,29 @@ //do some work...

### Override data sources
Since data sources are added to the context based on the constructor name, it is possible to simply override data sources by passing the same class name or overriding the constructor name:
```javascript
const { schema, context } = new GraphQLComponent({
imports: [
{
component: new Property(),
exclude: ['Mutation.*']
},
{
component: new Reviews(),
exclude: ['Mutation.*']
}
],
dataSourceOverrides: [
new class PropertyMock {
static get name() {
return 'PropertyDataSource';
}
//...etc
}
]
});
```
### Directly executing components

@@ -175,0 +199,0 @@

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