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
const gqlComplexity = require("graphql-query-complexity"); | |
const { UserInputError } = require("apollo-server"); | |
const { separateOperations } = require("graphql"); | |
const MAX_DEPTH = 10; | |
const estimators = [ | |
gqlComplexity.fieldExtensionsEstimator(), | |
gqlComplexity.directiveEstimator(), | |
gqlComplexity.simpleEstimator({ defaultComplexity: 1 }) |
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
// Run this in node 18 and up | |
(async () => { | |
const API_KEY = `KEY`; | |
const url = `https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=USDT&CMC_PRO_API_KEY=${API_KEY}&convert=GBP`; | |
const response = await fetch(url, { | |
method: "GET", | |
headers: { | |
Accept: "application/json", | |
}, |
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
type Movie { | |
title: String! | |
actors: [Person] @relationship(type: "ACTED_IN", direction: IN) | |
genres: [Genre] @relationship(type: "In_GENRE", direction: OUT) | |
} | |
type Person { | |
name: String! | |
movies: [Movie] @relationship(type: "ACTED_IN", direction: OUT) | |
} |
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
import express from "express" | |
import { createYoga } from "graphql-yoga"; | |
import { makeExecutableSchema } from "graphql-tools"; | |
const app = express(); | |
// GraphQL Schema | |
const schema = makeExecutableSchema({ | |
typeDefs, | |
resolvers, |
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
const nameInputs = document.querySelectorAll("input[type=text]"); | |
const firstName = nameInputs[0]; | |
const secondName = nameInputs[1]; | |
firstName.value = "Daniel"; | |
secondName.value = "Starns"; | |
const checkboxes = document.querySelectorAll("input[type=checkbox]"); | |
const sixPM = checkboxes[0]; |
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
mutation { | |
createPeople( | |
input: [ | |
{ | |
name: "Tom Hanks" | |
movies: { | |
create: [ | |
{ | |
node: { | |
name: "Forrest Gump" |
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
{ | |
"people": [ | |
{ | |
"name": "Tom Hanks", | |
"movies": [ | |
{ | |
"title": "Forrest Gump", | |
"genres": [{ "name": "Drama" }, { "name": "Romance" }] | |
} | |
] |
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
query { | |
people(where: { name: "Tom Hanks" }) { | |
name | |
movies { | |
title | |
genres { | |
name | |
} | |
} | |
} |
NewerOlder