
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
graphql-endpoint
Advanced tools
A lightweight framework for GraphQL endpoints.
Before (client):
fetch('somewhere/graphql', {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify({ bigGraphQLQueryString, variables })
).then(response => response.json()) // receive GraphQLResult
After (client):
// put GraphQL variables into http GET queris
fetch('somewhere/wrapped/endpoint?variable1=abc&variable2=def')
.then(response => response.json()) // receive GraphQLResult
// or make GraphQL like POST without query
fetch('somehwere/wrapped/endpoint', {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify({ variables }) // no need query, it's on server side
).then(response => response.json()) // receive GraphQLResult
Add graphql-endpoint
to your GraphQL server.
const { ApolloServer } = require('apollo-server-express')
const express = require('express')
const { GraphQLEndpoint } = require('graphql-endpoint')
const bodyParser = require('body-parser')
const app = express()
// graphql-endpoint requires json body to be parsed
app.use(bodyParser.json())
// Adopt graphql-endpoint
GraphQLEndpoint(app)
const server = new ApolloServer(configs)
server.applyMiddleware({
app,
bodyParser: false // optional disable bodyParser, we already have it
})
Then put your GraphQL query files into src/endpoints/
. For example, the src/endpoints/my_api
with content { example(id: 123) { title, description } }
will serve GraphQL result on /my_api
.
The wrapped API endpoint will support two types of http requests:
FAQs
A lightweight framework for GraphQL endpoints
The npm package graphql-endpoint receives a total of 1 weekly downloads. As such, graphql-endpoint popularity was classified as not popular.
We found that graphql-endpoint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.