import { useEffect } from 'react' import Layout from '../components/ui/Layout' import ApolloClient from 'apollo-boost' import { ApolloProvider, Query } from 'react-apollo' import gql from 'graphql-tag' // eslint-disable-next-line no-unused-vars import { World } from 'ecsy' const EcsyPage = () => { let world: any let client: any const ENTITY_QUERY = gql` { entity { id name type components { id type } } } ` useEffect(() => { client = new ApolloClient({ uri: 'http://localhost:3030/graphql' }) world = new World() const testEntity = world.createEntity() console.log(testEntity) client .query({ query: ENTITY_QUERY }) .then((result) => { result.data.entities.map((entity: any) => { world.createEntity() console.log(entity) }) console.log(result.data) }) }, []) return ( {({ loading, error, data }: any) => { if (loading) return

Loading...

if (error) return

Error

return (
{data.entity.map((entity: any) => (

{entity.name} | {world.createEntity().id}{' '}

))}
) }}
) } // const ENTITY_MUTATION = gql` // { // entity(name: 'testEntity', type: 'box', components: [ // { // type: networked // } // ]) // { // id // name // type // } // } // ` export default EcsyPage