在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):stubailo/schema-stitching-demo开源软件地址(OpenSource Url):https://github.com/stubailo/schema-stitching-demo开源编程语言(OpenSource Language):TypeScript 100.0%开源软件介绍(OpenSource Introduction):Schema stitching demoSchema stitching is the idea of automatically combining two or more GraphQL schemas into one. It can be used to modularize a single GraphQL codebase, integrate with other APIs, or just combine two public APIs into one. This is going to be one of the main features of the 2.0 release of graphql-tools, a library for creating and manipulating GraphQL schemas in JavaScript. Huge thanks to Mikhail Novikov for his awesome design and implementation on this feature, and please contribute to the PR if you find it exciting! Running the exampleJust run it like any other npm project:
Then, open localhost:3000/graphiql in your web browser, and hit run on the query! Oh and also grab a ticket for GraphQL Summit 2017, a 2-day GraphQL conference in San Francisco on October 25-26. What does this do?For all of the details, read the upcoming blog post (TODO). In short, this combines two GraphQL APIs:
Against those two APIs, we can run the following queries: # Get information about GraphQL Summit from Universe
query {
event(id: "5983706debf3140039d1e8b4") {
title
venueName
address
cityName
}
}
# Get weather information about San Francisco from Dark Sky
query {
location(place: "San Francisco") {
city
country
weather {
summary
temperature
}
}
} One thing that stands out is that the const schema = mergeSchemas({
schemas: [universeSchema, weatherSchema],
links: [
{
name: 'location',
from: 'Event',
to: 'location',
resolveArgs: parent => ({ place: parent.cityName }),
fragment: `
fragment WeatherLocationArgs on Event {
cityName
}
`,
},
],
}); This is saying that we want to add a query {
# From the Universe API
event(id: "5983706debf3140039d1e8b4") {
title
description
url
# Stitched field that goes to the Dark Sky API
location {
city
country
weather {
summary
temperature
}
}
}
} This is a pretty basic example, and we're still working on the complete documentation. Follow along with the discussion on the graphql-tools PR! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论