在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):cloudflare/workers-graphql-server开源软件地址(OpenSource Url):https://github.com/cloudflare/workers-graphql-server开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):workers-graphql-serverAn Apollo GraphQL server, built with Cloudflare Workers. Try a demo by looking at a deployed GraphQL playground. Why this rules: Cloudflare Workers is a serverless application platform for deploying your projects across Cloudflare's massive distributed network. Deploying your GraphQL application to the edge is a huge opportunity to build consistent low-latency API servers, with the added benefits of "serverless" (I know, the project has By the way - as a full-stack developer who loves GraphQL, and the developer advocate for Cloudflare Workers, I would love to see what you build with this! Let me know on Twitter! UsageYou can begin building your own Workers GraphQL server by installing Wrangler, the Workers command-line tool, and generating a new project: wrangler generate my-graphql-server https://github.com/cloudflare/workers-graphql-server You'll need to configure your project's The source for this project includes an example external REST data source, and defined types for the PokeAPI, as an example of how to integrate external APIs. Once you have the worker available, try this query as a sanity check: query samplePokeAPIquery {
pokemon: pokemon(id:1) {
id,
name,
height,
weight,
sprites{
front_shiny,
back_shiny
}
}
} To start using the project, configure your const graphQLOptions = {
baseEndpoint: '/', // String
playgroundEndpoint: '/___graphql', // ?String
forwardUnmatchedRequestsToOrigin: false, // Boolean
debug: false, // Boolean
cors: true, // Boolean or Object to further configure
kvCache: false, // Boolean
} EndpointsMake requests to your GraphQL server at the Origin forwardingIf you run your GraphQL server on a domain already registered with Cloudflare, you may want to pass any unmatched requests from inside your Workers script to your origin: in that case, set DebuggingWhile configuring your server, you may want to set the CORSBy default, the const graphQLOptions = {
// ... other options ...
cors: {
allowCredentials: 'true',
allowHeaders: 'Content-type',
allowOrigin: '*',
allowMethods: 'GET, POST, PUT',
},
} Note that by default, any field that you don't pass here (e.g. REST cachingVersion 1.1.0 of this project includes support for caching external requests made via instances of # wrangler.toml
[[kv-namespaces]]
binding = "WORKERS_GRAPHQL_CACHE"
id = "$myId" With a configured KV namespace set up, you can opt-in to KV caching by changing the LicenseThis project is licensed with the MIT License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论