![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
tyranid-graphql
Advanced tools
This library adds a graphql query interpreter for the tyranid
mongodb ORM. The graphql schema is created from tyranid collection schemas using graphql-js
.
After calling graphqlize(Tyr)
on tyranid, use graphql queries for complex populations...
import { Tyr } from 'tyranid';
import { graphqlize } from 'tyranid-graphql';
// ...
graphqlize(Tyr); // (synchronous)
// ...
// template tag syntax
const results = await Tyr.graphql`
query userTeams {
users {
name
teamIds {
name,
organizationId {
name
}
}
}
}
`;
console.log(users[1].teamIds[2].organizationId.name); // => "Chipotle"
To see an example of apollo-server
(http://dev.apollodata.com/core/)
being used with a generated schema from tyranid, clone the repo, install deps...
npm install
and run the example server
npm start
Say we have the following tyranid collections...
import { Tyr } from 'tyranid';
export const User = new Tyr.Collection({
id: 'u00',
name: 'user',
dbName: 'users',
fields: {
_id: { is: 'mongoid' },
name: { is: 'string' },
teamIds: {
is: 'array',
of: {
link: 'team'
}
},
organizationId: { link: 'organization' }
}
});
export const Team = new Tyr.Collection({
id: 't00',
name: 'team',
dbName: 'teams',
fields: {
_id: { is: 'mongoid' },
name: { is: 'string' },
organizationId: { link: 'organization' }
}
});
export const Organization = new Tyr.Collection({
id: 'o00',
name: 'organization',
dbName: 'organizations',
fields: {
_id: { is: 'mongoid' },
name: { is: 'string' }
}
});
We then can add graphql functionality to tyranid as follows
import { Tyr } from 'tyranid';
import { graphqlize } from 'tyranid-graphql';
(async() => {
const db = await mongodb
.MongoClient
.connect('mongodb://127.0.0.1:27017/tyranid_gracl_test');
Tyr.config({
db: db,
validate: [
{ dir: __dirname,
fileMatch: 'models.js' }
]
});
graphqlize(Tyr);
})();
Then, elsewhere in the app, we can use graphql queries for complex population of linked collections.
Additionally, if a Tyr.secure
plugin like tyranid-gracl
is being utilized,
we can provide auth
and perm
parameters to have
properties / documents filtered by user permissions.
const results = await Tyr.graphql({
query: `
query userTeams {
users {
name
teamIds {
name,
organizationId {
name
}
}
}
}
`
auth: req.user,
perm: 'view'
});
// result === {
// 'data': {
// 'users': [
// {
// 'name': 'ben',
// 'teamIds': [
// {
// 'name': 'burritoMakers',
// 'organizationId': {
// 'name': 'Chipotle'
// }
// },
// {
// 'name': 'chipotleMarketing',
// 'organizationId': {
// 'name': 'Chipotle'
// }
// }
// ]
// },
// {
// 'name': 'ted',
// 'teamIds': [
// {
// 'name': 'cavaEngineers',
// 'organizationId': {
// 'name': 'Cava'
// }
// }
// ]
// },
// {
// 'name': 'noTeams',
// 'teamIds': []
// }
// ]
// }
// };
npm install tyranid-graphql
MIT
FAQs
GraphQL plugin for tyranid
The npm package tyranid-graphql receives a total of 1 weekly downloads. As such, tyranid-graphql popularity was classified as not popular.
We found that tyranid-graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.