Skip to content

zoxjs/graphql-plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Plugins for Zox.js

npm i zox zox-plugins graphql-plugins

Zox.js was created with one goal in mind: Making scalable systems
And this can easily be achieved using the graphql-plugins.

Resolvers

Easily assign resolvers to fields.

@Resolver('Post', 'author', PostTypeDefs)
export class AuthorResolver implements IResolver
{
    public handle(source: Post, args, context, info: GraphQLResolveInfo): User
    {
        return users.find(u => u.id == source.user);
    }
}

Top-Level Fields

Declare top-level fields anywhere in your code.

@Query('user(id: ID!): User', UserDef)
export class UserQuery extends ResolverBase
{
    public resolve(root, args, context): Array<UserData>
    {
        return users.find(u => u.id == args.id);
    }
}

Subscriptions

Use Event Emitters as GraphQL Subscription endpoints that can be accessed over a Web Socket.

@Subscription('post: Post', PostTypeDefs)
export class PostSubscription extends SubscriptionEventResolverBase
{
    public eventNames: Array<string> = [postCreated, postUpdates, postDeleted];
    public eventEmitter: EventEmitter = eventEmitter;
}

Releases

No releases published

Packages

No packages published