-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query from SpaceX and (horribly) display on screen
- Loading branch information
Showing
10 changed files
with
1,942 additions
and
438 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ApolloClient, InMemoryCache } from "@apollo/client"; | ||
|
||
const API_URL = 'https://api.spacex.land/graphql/'; | ||
|
||
const client = new ApolloClient({ | ||
uri: API_URL, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
export default client; |
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 file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Flex, Heading, Text } from '@chakra-ui/core'; | ||
import { Card, CardHeader, CardBody } from '@chakra-ui/react' | ||
import { launch, launches } from '../types/launch'; | ||
|
||
|
||
export default function Home(data: launches) { | ||
return ( | ||
<Flex justifyContent="center" alignItems="center" flexWrap="wrap"> | ||
{data.launches.map((launch: launch) => ( | ||
<Card key={launch.id} p={4} width={{ base: '100%', md: '50%' }}> | ||
<CardHeader> | ||
<Heading>Mission: {launch.mission_name}</Heading> | ||
</CardHeader> | ||
<CardBody> | ||
<Text>Launch site: {launch.launch_site.site_name}</Text> | ||
<Text>Rocket type: {launch.rocket.rocket_type}</Text> | ||
</CardBody> | ||
</Card> | ||
))} | ||
</Flex> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import gql from 'graphql-tag'; | ||
import client from "../apollo-client"; | ||
import { launches } from '../types/launch'; | ||
import Home from './home'; | ||
|
||
export async function getStaticProps() { | ||
const query = gql` | ||
{ | ||
launches { | ||
id | ||
launch_site { | ||
site_id | ||
site_name | ||
} | ||
rocket { | ||
rocket_name | ||
rocket_type | ||
} | ||
mission_name | ||
} | ||
} | ||
`; | ||
|
||
const { data } = await client.query({ query }); | ||
|
||
|
||
return { | ||
props: { | ||
launches: data.launches, | ||
}, | ||
}; | ||
} | ||
|
||
export default function HomePage(launches: launches) { | ||
return Home(launches); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.