Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rayhanadev/replit-gql
Reusable function to query Replit's GraphQL API.
https://github.com/rayhanadev/replit-gql
apollo apollo-client graphql replit
Last synced: 13 days ago
JSON representation
Reusable function to query Replit's GraphQL API.
- Host: GitHub
- URL: https://github.com/rayhanadev/replit-gql
- Owner: rayhanadev
- License: mit
- Created: 2022-08-09T17:16:22.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-03T08:26:37.000Z (over 2 years ago)
- Last Synced: 2024-11-06T22:42:58.419Z (2 months ago)
- Topics: apollo, apollo-client, graphql, replit
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@rayhanadev/replit-gql
- Size: 87.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Replit GraphQL
Reusable function to query Replit's GraphQL API. Written to consume [@apollo/client](https://github.com/apollographql/apollo-client)
with a patched node-fetch used by Replit.It is recommended you add [babel-plugin-import-graphql](https://www.npmjs.com/package/babel-plugin-import-graphql)
to your Babel configuration to import `.graphql` files. Otherwise you may use [graphql-tag](https://www.npmjs.com/package/graphql-tag)
to the same effect.For information on how to use the ApolloClient, visit its [core API docs](https://www.apollographql.com/docs/react/api/core/ApolloClient).
Note, this package uses the core ApolloClient, not the React view layer.## Usage
```js
import { GraphQL } from '@rayhanadev/replit-gql';
import CurrentUser from './queries/CurrentUser.graphql';// You can use a Replit Token
// (connect.sid) for authenticated
// queries.
const { REPLIT_TOKEN } = process.env;
const client = GraphQL(REPLIT_TOKEN);const { data } = await client.query({
query: CurrentUser,
});console.log(data);
```Output:
```json
{
"currentUser": {
"id": 4045907
}
}
```