Demonstration bridge between ATproto and GraphQL. Generate schema types and interface with the ATmosphere via GraphQL queries. Includes a Ty
README.md
# ATProto <=> GraphQL Bridge A bridge between ATProto (server-side) and GraphQL (client-side) for developing efficient UIs for the ATmosphere. > Note: This is a demonstration. Support for simple ATproto procedures and types is supported, but full support requires more work. **Installation:** ``` npm install ``` ## Schema Generation This project uses [@atproto/lex](https://www.npmjs.com/package/@atproto/lex-cli) to download Lexicons and generate xRPC calls that are used in the backend. Example usage: ``` ts-lex install app.bsky.actor.getProfile com.atproto.server.getSession npm run generate ``` This will generate schema definitions for the `getProfile` and `getSession` procedures and recursively import all their referenced types, e.g. ``` type Lexicon_app_bsky_actor { getProfile(actor: ID!): Lexicon_app_bsky_actor_defs_profileViewDetailed } # app.bsky.actor.defs#profileViewDetailed type Lexicon_app_bsky_actor_defs_profileViewDetailed { did: ID! handle: ID! displayName: String description: String pronouns: String website: String avatar: String banner: String followersCount: Int followsCount: Int postsCount: Int associated: Lexicon_app_bsky_actor_defs_profileAssociated joinedViaStarterPack: Lexicon_app_bsky_graph_defs_starterPackViewBasic indexedAt: String createdAt: String viewer: Lexicon_app_bsky_actor_defs_viewerState labels: [Lexicon_com_atproto_label_defs_label!] pinnedPost: Lexicon_com_atproto_repo_strongRef verification: Lexicon_app_bsky_actor_defs_verificationState status: Lexicon_app_bsky_actor_defs_statusView } # ... ``` ## Example GraphQL Server This repo also contains a Rust GraphQL server that can bridge an exported schema to the AT protocol. You can use this as a reference or even expand it to include non-AT GraphQL types. - GraphQL API endpoint at `/graphql` - Interactive GraphiQL interface for development at `/graphiql` ### Building ```bash npm run server ``` The server will start on `http://localhost:8000`. An example query and variables: …