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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mutix/graphql-phoenix

v0.1.25

Published

Readme

graphql-phoenix

功能:

  • 檢查 resolvers 必須要 type name (Author) 要有
  • 檢查 implements Node 必須存在
  • 檢查 id 欄位為必須
  • hasTimestamp 設定node是否需要有 timestamp 相關欄位
  • hasOperator
  • 如果欄位是 node type 卻沒有寫 resolver
export default makeNode({
  softDelete: false,
  hasOperator: false,
  hasTimestamp: false,
  typeDefs: gql`
    union Works = Book | Music

    type Author implements Node {
      id: GlobalID
      name: String
      avatar: Media
      works: [Works]
      numberOfFollowers: Int
      createdAt: DateTime
      createdBy: User
      updatedAt: DateTime
      updatedBy: User
    }

    enum AuthorOrderBy {
      createdAt
      updatedAt
      numberOfFollowers
    }

    input AuthorFilter {
      name: StringArgument
      avatar: GlobalIDArgument
      works: GlobalIDArgument
      numberOfFollowers: IntArgument
      createdAt: DateTimeArgument
      createdBy: GlobalIDArgument
      updatedAt: DateTimeArgument
      updatedBy: GlobalIDArgument
    }

    input AddAuthorInput {
      name: String
      avatar: Media
      works: [Works]
      numberOfFollowers: Int
    }
  
    input UpdateAuthorInput {
      id: GlobalID
      name: String
      avatar: Media
      works: [Works]
      numberOfFollowers: Int
    }
  `,
  resolvers: {
    Author: {
      id: (source) => source.id,
      avatar: (source, args, { models }) => models.load(source.avatar),
      works: (source, args, { models }) => models.loadMany(source.works),
      numberOfFollowers: () => {},
      createdAt: () => {},
      updatedAt: () => {},
      createdBy: (source, args, { models }) => models.load(source.createdBy),
      updatedBy: (source, args, { models }) => models.load(source.updatedBy),
    }
  }
})
  • 檢查必須要 Query 要有
  • 檢查必須要是 extend type Query
export default makeQuery({
  typeDefs: gql`
    extend type Query {
      node(id: GlobalID!): Node
    }
  `,
  resolvers: {
    Query: {
      node: (source, args, { models }) => models.load(args.id),
    },
  },
});
  • 繼承 makeQuery 的功能
  • 檢查 firstcursor 為必須
  • 檢查 filterorderBy 為必須
  • 檢查 [name]Pagination 大駝峰並加上 Pagination
  • 檢查 AuthorsPagination 裡面的必要欄位
export default makeQueryPagination({
  typeDefs: gql`
    extend type Query {
      authors(
        first: First
        cursor: Cursor
        filter: AuthorFilter
        orderBy: AuthorOrderBy
      ): AuthorsPagination
    }

    type AuthorsPagination {
      totalCount: Int
      nodes: [Author]
      pageInfo {
        next: Cursor
        previous: Cursor
      }
    }

    type AuthorFilter {
    }
  `,
  resolvers: {
    Query: {
      authors: (source, args, { models }) => {
        const { AuthorQuery } = models;
        if (args.cursor) {
          AuthorQuery.cursor(args.cursor);
        } else {
          AuthorQuery.filterQL(args.filter);
          AuthorQuery.sortByQL(args.sortBy);
        }
        AuthorQuery.first(args.first);
        AuthorQuery.where(...);
        return AuthorQuery;
      }
    },
    AuthorsPagination: {
      totalCount: (source) => {},
      nodes: (source) => source.find(),
      pageInfo: (source) => ,
    }
  },
});
  • 檢查 extend type Mutation
  • 檢查 [name]MutationPayload
  • 檢查 status 必須
  • 檢查必須要 Mutation 要有
export default makeMutation({
  typeDefs: gql`
    extend type Mutation {
      addAuthor(input: AddAuthorInput): AddAuthorMutationPayload
    }

    type AddAuthorMutationPayload {
      status: ResponseStatus
      author: Author
    }
  `,
  resolvers: {
    Mutation: {
      addAuthor: () => {}
    },
  },
});
export default makeMutation({
  typeDefs: gql`
    extend type Mutation {
      updateAuthor(input: UpdateAuthorInput): UpdateAuthorMutationPayload
    }

    type UpdateAuthorMutationPayload {
      status: ResponseStatus
      author: Author
    }
  `,
  resolvers: {
    Mutation: {
      updateAuthor: () => {}
    },
  },
});