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 fetch = require("node-fetch"); | |
const { introspectionQuery } = require("graphql"); | |
const fs = require("fs"); | |
fetch("https://1jzxrj179.lp.gql.zone/graphql", { | |
method: "POST", | |
headers: { "Content-Type": "application/json" }, | |
body: JSON.stringify({ query: introspectionQuery }) | |
}) | |
.then(res => res.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
export const ErrorProvider = (props) => { | |
// This is just a link that swallows all operations and returns the same thing | |
// for every request: The specified error. | |
const link = new ApolloLink((operation) => { | |
return new Observable((observer) => { | |
observer.next({ | |
errors: props.graphQLErrors || [ | |
{message: 'Unspecified error from ErrorProvider.'}, | |
], | |
}); |
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
require('isomorphic-fetch'); | |
fetch('https://1jzxrj179.lp.gql.zone/graphql', { | |
method: 'POST', | |
headers: { 'Content-Type': 'application/json' }, | |
body: JSON.stringify({ query: '{ posts { title } }' }), | |
}) | |
.then(res => res.json()) | |
.then(res => console.log(res.data)); |
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
// This is a script that looks for usage of a specific field in GraphQL | |
// queries in your codebase. | |
// | |
// First, add a .graphqlconfig in your directory pointing to your schema | |
// Then, run the script with: | |
// | |
// node graphql-field-finder.js Field.name | |
// | |
// It will output a list of files and queries that contain the field you're | |
// looking for: |
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
// npm install graphql graphql-tools graphql-subscriptions | |
const { PubSub, SubscriptionManager } = require('graphql-subscriptions'); | |
const { makeExecutableSchema } = require('graphql-tools'); | |
// Our "database" | |
const messages = []; | |
// Minimal schema | |
const typeDefs = ` | |
type Query { |
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
{ | |
"__schema": { | |
"queryType": { | |
"name": "Query" | |
}, | |
"mutationType": { | |
"name": "Mutation" | |
}, | |
"subscriptionType": null, | |
"types": [ |
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 { buildClientSchema, printSchema } = require("graphql"); | |
const fs = require("fs"); | |
const introspectionSchemaResult = JSON.parse(fs.readFileSync("result.json")); | |
const graphqlSchemaObj = buildClientSchema(introspectionSchemaResult); | |
const sdlString = printSchema(graphqlSchemaObj); |
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 LoadingProvider = (props) => { | |
const link = new ApolloLink((operation) => { | |
return new Observable(() => {}); | |
}); | |
const client = new ApolloClient({ | |
link, | |
cache: new InMemoryCache(), | |
}); | |
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
{ | |
"0": [ | |
-16.38360023498535, | |
-58.31719970703125 | |
], | |
"UTK": [ | |
11.222, | |
169.852005 | |
], | |
"OCA": [ |
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
// To run this code yourself: | |
// 1. Download and run the demo server: https://github.com/apollostack/frontpage-server | |
// 2. Use create-react-app to create a build system | |
// 3. npm install subscriptions-transport-ws | |
// 4. Replace all of the code in src/ with just this file | |
import { Client } from 'subscriptions-transport-ws'; | |
const client = new Client('ws://localhost:8090'); |
NewerOlder