Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@files-stack/graphql-schema
Advanced tools
This package is intended to be used with Apollo Server to provide an easy way to setup a GraphQL server and connect it to your database. Note that Apollo Server is not a depenedency of this package.
Sample Schema exports four things: database, resolvers, subscriptions and typeDefs.
resolvers Resolvers are functions that tell the server how to find and return the data for each field in a GraphQL query. The resolving functions simply call your Database Connectors by passing in parameters and return the Connectors result (usually a Promise).
After creating your Database and Connectors from Database, you can call the resolvers function by passing in the Connectors and your public application settings (since settings are stored in the application state). Building on the previous examples:
typeDefs is a GraphQL Schema based on the queries provided to it from database. With the schema, you can do things like Find Posts by post_type, get the Postmeta of a Post by the post_id, and so on.
subscriptions GraphQL subscriptions allow developers to introduce new levels of interactivity to their apps with near-realtime updates. You can keep your app updated to the latest changes (that you subscribe to) between different users:
database The first part of Sample Schema is database. This class provides an easy connection to your database using some connection settings, explained below.
src - directory is used for typescript code that is part of the project
index.ts - Index file of the package. Consists of exported components and containers
index.spec.ts - Tests file for main
modules - Fractal route for server-side application module splitting (schema definition, resolvers, subscription filters, database connectors )
package.json - file is used to describe the library and packages that are required added under peer-dependencies section
tsconfig.json - configuration file for the library compilation
webpack.config.js - configuration file of the compilation automation process for the library
modules
directory consists of the sub directories based on the criteria for module splitting. Each sub-directory may have schema definition, resolvers, subscriptions, database
Schema definition files should have suffix as .graphql
or .graphqls
. Resolvers file should be named as resolvers.ts
and subscriptions filter file as subscriptions.ts
.
All the files under modules are automatically bundled when you run npm run build
, so the above naming convention should be followed.
FAQs
Sample Schema Module
We found that @files-stack/graphql-schema 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.