Last active
June 23, 2020 07:50
-
-
Save PaulieScanlon/cf4ffd1cb26c5cc76bfcfc9d16013d74 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 is my data in a Fauna collection | |
{ | |
"ref": Ref(Collection("demo-blog"), "269039036074557959"), | |
"ts": 1592834468830000, | |
"data": { | |
"slug": "some-slug", | |
"things": [ | |
{ | |
"name": "testA", | |
}, | |
{ | |
"name": "testB" | |
} | |
] | |
} | |
} | |
// This is how i create the above | |
client.query( | |
q.Create(q.Collection(COLLECTION_NAME), { | |
data: { | |
slug: "some-slug", | |
things: [{ name: "testA" }, { name: "testB" }], | |
}, | |
}) | |
); | |
// This is how i read the above | |
client.query( | |
q.Paginate(q.Match(q.Index("get-things-by-slug"), "some-slug")) | |
); | |
// This is my GraphQL query | |
const GET_THINGS_BY_SLUG = gql` | |
query($slug: String!) { | |
getThingsBySlug(slug: $slug) { | |
ref | |
slug | |
things | |
} | |
} | |
`; | |
// and these are my typeDefs | |
const typeDefs = gql` | |
type Query { | |
getThbingsBySlug(slug: String!): [ThingsObject] | |
} | |
type Thing { | |
name: String | |
} | |
type ThingsObject { | |
ref: String | |
slug: String | |
things: [Thing] | |
} | |
`; | |
// This is what i see returned | |
{ | |
data: [ | |
[ | |
Ref(Collection("demo-blog"), "269039036074557959"), | |
'some-slug', | |
null | |
] | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment