diff --git a/queries/getRelayInfomation.gql b/queries/getRelayInfomation.gql new file mode 100644 index 0000000..b7fd978 --- /dev/null +++ b/queries/getRelayInfomation.gql @@ -0,0 +1,12 @@ +query getRelayInformation { + relayInformation { + name + contact + description + icon + pubkey + software + supported_nips + version + } +} diff --git a/test.ts b/test.ts index e9203f8..9de0f54 100644 --- a/test.ts +++ b/test.ts @@ -165,6 +165,20 @@ Deno.test("NIP-11: Relay Information Document", async (t) => { assertEquals(information2, { name: "Nostr Relay2", ...not_modifiable_information }); }); + await t.step("graphql", async () => { + const { hostname, port } = new URL(relay.url); + const res = await fetch(`http://${hostname}:${port}/api`, { + method: "POST", + headers: { + "Content-Type": "application/json", + "password": "123", + }, + body: JSON.stringify({ query: await Deno.readTextFile("./queries/getRelayInfomation.gql") }), + }); + const json = await res.json(); + assertEquals(json.data.relayInformation.name, "Nostr Relay2"); + }); + await relay.shutdown(); });