npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

graphty

v0.0.9

Published

Forming GraphQL query is now easier with graphty.

Downloads

2

Readme

Graphty

Angular 2+ Module to make it easer forming GraphQL queries.

Installation

  • Install module using:

    $ npm i graphty --save
  • Import module to your *.module.ts

    ...
    import { GraphtyModule, GqlQueryInterface } from 'graphty';
    
    @NgModule({
    ...
    imports: [
        ...
        GraphtyModule,
        ...
    ],
    ...
    })
    export class AppModule { }
    
  • Two important methods for forming queries according to the type (Root query or mutation query).

    • root query -> stagnation(object: ) method.
    • mutation query -> mutation(object) method.
    • combine queries -> combine(Array<objects>) method V0.0.7.
  • Inject GraphtyService inside you component class and feel free forming your graphql queries.

    import { GraphtyService } from 'graphty';
        ...
        constructor(private graf: GraphtyService){}
    
        getQuery(): GqlQueryInterface {
            return this.graf.stagnation({
                fun: {
                    name: 'getFoo',    // required field and should be always string
                    args: {name: 'foo', limit: 15}   // args is optional also it is auto detected when string inserted.
                },
                ret: ['id', 'foo_category', 'date'], // requested body can be nested by another query if with the same structure.
                combine: [this.graf.stagnation({        // To combine more that one query in one request (in 0.0.7 removed)
                    fun: {
                        name: 'getAddress'
                    },
                    ret: ['country', 'town', 'street', 'house_number']
                }]
            })
        }
        mutateQuery(): GqlQueryInterface {
            return this.graf.mutation({
                fun: {
                    name: 'setNewFoo',    // required field and should be always string
                    args: {name: 'foo', limit: 15}   // args is optional also it is auto detected when string inserted.
                },
                ret: ['id', 'foo_category', 'date'], // requested body can be nested by another query if with the same structure.
                combine: [this.graf.mutation({        // To combine more that one query in one request (in 0.0.7 removed)
                    fun: {
                        name: 'getAddress',
                        args: {id: 12}
                    },
                    ret: ['country', 'town', 'street', 'house_number']
                }]
            })
        }

    The previous example will produce this query bellow

    {   // result of getQuery() method
        query: '{setNewFoo(name:"foo",limit:15){id,foo_category,date},getAddress{country,town,street,house_number}}'
    }
    
    {   // result of mutateQuery() method
        query: 'mutation{setNewFoo(name:"foo",limit:15){id,foo_category,date},getAddress(id: 12){country,town,street,house_number}}'
    }

    Which you can pass them directly to the server who runs graphQL.

    In version 0.0.7 property combine is seperated to reduce confusion which make it easier to form combined queries of graphQL. This method will reduce channel traffic between clients and server by combining two or more quries in one request. This should be with the respect of qurey type, since mutation should be send with POST and normal root query should send with GET they must not be mixed which is more reasonable. Mixing will throw error with a nice message ;)

        let GQLQ: GqlQueryInterface = this.graf.combine([
                        this.graf.stagnation({
                            fun: {
                            name: 'getUser',
                            args: { username: 'foo' }
                            },
                            ret: ['bar', this.graf.stagnation({   /** You can do nested object also as respond */
                                fun: {
                                    name: 'ack'
                                },
                                ret: ['ok', 'message']
                            })
                            ]
                        }),
                        this.graf.stagnation({
                            fun: {
                                name: 'getCategory',
                                args: {name: 'foo', limit: 15}
                            },
                            ret: ['id', 'work', 'skills']
                        })
                    ]);
        console.log(GQLQ); // Resault -> {query:`{getUser(username:"foo"){bar,ack{ok,message}},getCategory(name:"foo",limit:15){id,work,skills}}`}

Versions history: