How to use the graphql-tools.makeRemoteExecutableSchema function in graphql-tools

To help you get started, we’ve selected a few graphql-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github artsy / metaphysics / src / lib / stitching / gravity / schema.ts View on Github external
export const executableGravitySchema = () => {
  const gravityTypeDefs = readFileSync("src/data/gravity.graphql", "utf8")

  const gravityLink = createGravityLink()
  const schema = makeRemoteExecutableSchema({
    schema: gravityTypeDefs,
    link: gravityLink,
  })

  // Types which come from Gravity which MP already has copies of.
  // In the future, these could get merged into the MP types.
  const removeTypes = [
    "Artist",
    "Artwork",
    "ArtistEdge",
    "ArtworkEdge",
    "ArtworkConnection",
    "ArtistConnection",
  ]

  // Return the new modified schema
github graphql-boilerplates / node-graphql-server / index.ts View on Github external
async function run() {

  // Step 1: Create local version of the CRUD API
  const link = new HttpLink({ uri: process.env.GRAPHQL_ENDPOINT, fetch })
  const graphcoolSchema = makeRemoteExecutableSchema({
    schema: await introspectSchema(link),
    link,
  })

  // Step 2: Define schema for the new API
  const extendTypeDefs = `
    extend type Query {
      viewer: Viewer!
    }

    type Viewer {
      me: User
      topPosts(limit: Int): [Post!]!
    }

    extend type Mutation {
github netlify / netlify-dev-plugin / src / functions-templates / js / graphql-gateway / graphql-gateway.js View on Github external
async function getSchema(endpoint) {
  // you can't use relative URLs within Netlify Functions so need a base URL
  // process.env.URL is one of many build env variables:
  // https://www.netlify.com/docs/continuous-deployment/#build-environment-variables
  // Netlify Dev only supports URL and DEPLOY URL for now
  const uri = process.env.URL + "/.netlify/functions/" + endpoint;
  const link = createHttpLink({ uri, fetch });
  const schema = await introspectSchema(link);
  const executableSchema = makeRemoteExecutableSchema({ schema, link });
  return executableSchema;
}
github xing / hops / packages / spec / integration / graphql-mock-server / mocks / index.js View on Github external
export default async function createSchema() {
  let remoteSchemaContent;
  try {
    remoteSchemaContent = await introspectSchema(options =>
      fetcher({ ...options, ...remoteSchemaOptions })
    );
  } catch (error) {
    console.log(
      'GraphQL Mock Server: Cannot introspect schema from',
      remoteSchemaOptions.url
    );
  }

  let remoteSchema;
  if (remoteSchemaContent) {
    remoteSchema = makeRemoteExecutableSchema({
      schema: remoteSchemaContent,
      fetcher: options => fetcher({ ...options, ...remoteSchemaOptions }),
    });
  }

  return mergeSchemas({
    schemas: [remoteSchema, localSchema].filter(Boolean),
    resolvers,
  });
}
github gridsome / gridsome / packages / source-graphql / index.js View on Github external
async getRemoteExecutableSchema (uri, headers) {
    const http = new HttpLink({ uri, fetch })
    const link = setContext(() => ({ headers })).concat(http)
    const remoteSchema = await introspectSchema(link)

    return makeRemoteExecutableSchema({
      schema: remoteSchema,
      link
    })
  }
github nikolasburk / prisma-contentful-schema-stitching / src / ContentfulBinding.js View on Github external
constructor() {
    const endpoint = `${DELIVERY_API_BASE_URL}/spaces/${SPACE_ID}/graphql/alpha?locale=${LOCALE_CODE}`
    const link = new HttpLink({
      fetch,
      uri: endpoint,
      headers: {
        Authorization: `Bearer ${ACCESS_TOKEN}`,
      },
    })

    const schema = makeRemoteExecutableSchema({ link, schema: typeDefs })

    super({
      schema,
    })
  }
github supergraphql / supergraph / src / middlewares / remoteSchema.ts View on Github external
}

    if (name === undefined) {
      name = `schema${Object.keys(req.supergraph.schemas).length}`
    }

    if (introspectionSchema === undefined) {
      if (!get(`supergraph.${name}.introspection`)) {
        introspectionSchema = await introspectSchema(link)
        put(`supergraph.${name}.introspection`, introspectionSchema)
      } else {
        introspectionSchema = get(`supergraph.${name}.introspection`)
      }
    }

    const executableSchema = makeRemoteExecutableSchema({
      schema: introspectionSchema,
      link
    })

    req.supergraph.schemas[name] = executableSchema

    next()
  })
}
github nilshartmann / graphql-examples / schema-stitching / schema-stitcher / src / Stitcher.ts View on Github external
async function createRemoteSchema(uri: string) {
  const link = new HttpLink({ uri, fetch });
  const schema = await introspectSchema(link);

  return makeRemoteExecutableSchema({
    schema,
    link
  });
}