refactor: stop spreading challenge over the node (#44499)

* refactor: stop spreading challenge over the node

Instead of creating a Gatsby node with id of challenge.id, we create a
single node field that has all the challenge data.

While this makes the GraphQL queries more verbose, it means we're free
to create multiple nodes with the same challenge.id.

* test: update time-line test for new GQL schema

* test: update mocks with new GQL schema
This commit is contained in:
Oliver Eyton-Williams
2021-12-14 19:11:20 +01:00
committed by GitHub
parent 755f27093c
commit 3b560deab6
18 changed files with 593 additions and 440 deletions

View File

@@ -49,7 +49,9 @@ class ShowCodeAlly extends Component<ShowCodeAllyProps> {
const {
updateChallengeMeta,
data: {
challengeNode: { challengeType, title }
challengeNode: {
challenge: { challengeType, title }
}
},
pageContext: { challengeMeta }
} = this.props;
@@ -60,9 +62,11 @@ class ShowCodeAlly extends Component<ShowCodeAllyProps> {
const {
data: {
challengeNode: {
title,
fields: { blockName },
url
challenge: {
title,
fields: { blockName },
url
}
}
},
webhookToken = null
@@ -94,12 +98,14 @@ export default connect(mapStateToProps, mapDispatchToProps)(ShowCodeAlly);
// GraphQL
export const query = graphql`
query CodeAllyChallenge($slug: String!) {
challengeNode(fields: { slug: { eq: $slug } }) {
title
challengeType
url
fields {
blockName
challengeNode(challenge: { fields: { slug: { eq: $slug } } }) {
challenge {
title
challengeType
url
fields {
blockName
}
}
}
}