mooch
mooch
DDeno
Created by mooch on 12/15/2024 in #help
Unable to use @apollo/client
// query github api using graphql
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import { RepositoryDocument } from "@hk/github-graphql";

// print something from the github graphql api
export async function demo() {
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: "https://api.github.com/graphql",
headers: {
authorization: `Bearer ${Deno.env.get("GITHUB_TOKEN")}`,
"User-Agent": "github-graphql package",
},
}),
});

const result = await client.query({
query: RepositoryDocument,
variables: {
owner: "tauri-apps",
name: "tauri",
},
});
console.log(`stargazer count: ${result.data.repository?.stargazerCount}`);
}

await demo();
// query github api using graphql
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import { RepositoryDocument } from "@hk/github-graphql";

// print something from the github graphql api
export async function demo() {
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: "https://api.github.com/graphql",
headers: {
authorization: `Bearer ${Deno.env.get("GITHUB_TOKEN")}`,
"User-Agent": "github-graphql package",
},
}),
});

const result = await client.query({
query: RepositoryDocument,
variables: {
owner: "tauri-apps",
name: "tauri",
},
});
console.log(`stargazer count: ${result.data.repository?.stargazerCount}`);
}

await demo();
I installed these dependencies using deno add jsr:@hk/github-graphql and deno add npm:@apollo/client. I ran the test program using deno run -A gql.ts This small program fails with
error: Uncaught SyntaxError: The requested module 'graphql-tag' does not provide an
export named 'gql'
at <anonymous> (file:///Users/mooch/p/cts/forgekit/node_modules/.deno/@apollo+cl
ient@3.12.3/node_modules/@apollo/client/core/index.js:34:10)
error: Uncaught SyntaxError: The requested module 'graphql-tag' does not provide an
export named 'gql'
at <anonymous> (file:///Users/mooch/p/cts/forgekit/node_modules/.deno/@apollo+cl
ient@3.12.3/node_modules/@apollo/client/core/index.js:34:10)
How do I go about debugging this?
1 replies
DDeno
Created by mooch on 6/29/2023 in #help
Proxying a Rust API using FFI?
I have a rust application that serves a rest api that runs in a container. I also have a deno cli that acts as a client for the api, among other things. A usecase came up where a user of the CLI would want to spin up the rust API for "testing" but will not have access to the api. For this use case, I would like to package the rust api with the deno cli as a library and add a command to the cli named something like serve, which starts the rust web server. The problem is that the deno cli already has its own serve command with its own rest api. Is it possible to hook the rust api up with the deno native http server?
2 replies
DDeno
Created by mooch on 12/20/2022 in #help
Can you specify a git hash instead of version for npm modules?
As the title mentions, I'd like to use a specific commit for an npm package. Is this possible?
2 replies
DDeno
Created by mooch on 12/19/2022 in #help
discord.js with new npm imports
Has anyone successfully used https://www.npmjs.com/package/discord.js with Deno's new import functionality? I ran their basic example and found it hangs without error when trying to login using Client.login
8 replies