-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitriy Lazarev <[email protected]>
- Loading branch information
Showing
7 changed files
with
341 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,70 @@ | ||
TODO: How to start using backstage graphql plugin | ||
TODO: Link to `@relation` | ||
TODO: Get some text from the RFC | ||
The [Backstage GraphQL plugin][graphql-backend] is designed for schema-first | ||
development of the GraphQL API. It reduces work necessary to expand the schema | ||
using schema directives. [Schema directives](https://the-guild.dev/graphql/tools/docs/schema-directives) | ||
are extensions to GraphQL schema used to automate implementation of the GraphQL API. | ||
In Backstage GraphQL Plugin, schema directives are used to automatically create | ||
resolvers. [Resolvers](https://graphql.org/learn/execution/) tell a GraphQL API | ||
how to provide data for a specific schema type or field. The Backstage GraphQL | ||
Plugin uses what it knows about the Backstage catalog to reduce the need for | ||
writing resolvers that call the catalog. | ||
|
||
## Backend Development | ||
Currently, Backstage implemented two backend systems: | ||
|
||
The Backstage GraphQL plugin is designed for schema-first development of the GraphQL API. It reduces work necessary to expand the schema using schema directives. [Schema directives](https://the-guild.dev/graphql/tools/docs/schema-directives) are extensions to GraphQL schema used to automate implementation of the GraphQL API. In Backstage GraphQL Plugin, schema directives are used to automatically create resolvers. [Resolvers](https://graphql.org/learn/execution/) tell a GraphQL API how to provide data for a specific schema type or field. The Backstage GraphQL Plugin uses what it knows about the Backstage catalog to reduce the need for writing resolvers that call the catalog. | ||
- [EXPERIMENTAL Backstage backend system](https://backstage.io/docs/backend-system/) | ||
- [Backstage backend plugins](https://backstage.io/docs/plugins/backend-plugin) | ||
|
||
### Usage with backend system | ||
|
||
The full cover of using GraphQL with EXPERIMENTAL Backstage backend system you can | ||
find in [readme](https://github.com/thefrontside/playhouse/blob/main/plugins/graphql-backend/README.md) | ||
|
||
```typescript | ||
// packages/backend/src/index.ts | ||
import { graphqlPlugin } from '@frontside/backstage-plugin-graphql-backend'; | ||
import { graphqlModuleCatalog } from '@frontside/backstage-plugin-graphql-backend-module-catalog'; | ||
|
||
// Initializing Backstage backend | ||
const backend = createBackend(); | ||
|
||
// Adding GraphQL plugin | ||
backend.use(graphqlPlugin()); | ||
// Adding Catalog GraphQL module | ||
backend.use(graphqlModuleCatalog()); | ||
``` | ||
|
||
### Usage with backend plugins | ||
|
||
Using the old Backstage backend plugins system is also fully covered in | ||
[readme](https://github.com/thefrontside/playhouse/blob/main/plugins/graphql-backend/docs/backend-plugins.md) | ||
|
||
```typescript | ||
// packages/backend/src/plugins/graphql.ts | ||
import { createRouter } from '@frontside/backstage-plugin-graphql-backend'; | ||
import { Catalog, createCatalogLoader } from '@frontside/backstage-plugin-graphql-backend-module-catalog'; | ||
|
||
export default async function createPlugin( | ||
env: PluginEnvironment, | ||
): Promise<Router> { | ||
return await createRouter({ | ||
logger: env.logger, | ||
modules: [Catalog], | ||
loaders: { ...createCatalogLoader(env.catalogClient) }, | ||
}); | ||
} | ||
``` | ||
|
||
### Catalog module | ||
|
||
The single GraphQL plugin isn't useful by itself. To able query Backstage Catalog | ||
using GraphQL queries you need to install the [Catalog module][catalog-module]. | ||
|
||
The Catalog module provides [`@relation`](./relation) schema directive and data | ||
loader for Catalog API. It also has well written [Catalog GraphQL module][catalog-schema] | ||
with most basic Backstage types. We recommend to use it as a starting point. But | ||
if you'd like to implement your own type structure you can use [Relation GraphQL module][relation-schema]. | ||
Relation module contains only `@relation` schema directive and Catalog data loader. | ||
|
||
[graphql-backend]: https://github.com/thefrontside/playhouse/blob/main/plugins/graphql-backend | ||
[catalog-module]: https://github.com/thefrontside/playhouse/blob/main/plugins/graphql-backend-module-catalog | ||
[catalog-schema]: https://github.com/thefrontside/playhouse/blob/main/plugins/graphql-backend-module-catalog/src/catalog | ||
[relation-schema]: https://github.com/thefrontside/playhouse/blob/main/plugins/graphql-backend-module-catalog/src/relation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.