const { readFileSync } = require('fs');
const { resolve } = require('path');
const { addMocksToSchema } = require('@graphql-tools/mock');
const { makeExecutableSchema } = require('@graphql-tools/schema');
const { graphql } = require('graphql');

const schemaString = readFileSync(resolve(__dirname, '../server/schema.graphql'), 'utf8');

// Make a GraphQL schema with no resolvers
const schema = makeExecutableSchema({ typeDefs: schemaString });

// Create a new schema with mocks
const schemaWithMocks = addMocksToSchema({ schema });

const query = /* GraphQL */ `
  query MeQuery {
    me {
      firstName
    }
  }
`;

graphql({
  schema: schemaWithMocks,
  source: query,
}).then((result) => console.log('Got result', result));
