Skip to content

Instantly share code, notes, and snippets.

View nikolasburk's full-sized avatar
😑

Nikolas nikolasburk

😑
View GitHub Profile
input AddProjectInput {
name: String!
stage: String!
secrets: [String!]
clientMutationId: String
}
type AddProjectPayload {
project: Project
clientMutationId: String
@nikolasburk
nikolasburk / instructions.md
Last active March 7, 2020 17:50
Use the Contentful GraphQL API inside a GraphQL Playground

Use the Contentful GraphQL API inside a GraphQL Playground

The Contentful GraphQL API ships with GraphiQL by default. To get even better workflows (such as multiple tabs, speciyfing HTTP headers or work with multiple GraphQL APIs side-by-side), you can use a GraphQL Playground.

1. Get the endpoint for your Contentful GraphQL API

The endpoint of your Contentful GraphQL API has the following structure: https://cdn.contentful.com/spaces/{SPACE}/graphql/alpha/explore?access_token={CDA_TOKEN}

There are two placeholders that need to be replaced:

Addressing feedback from this Gist.

Pagination. Looks like limited to paginate by id. I wanted to paginate by a date field and felt impossible

In the most recent Preview version, (cursor-)pagination can be done by any unique field or combination of fields. For example:

model Post {
  id        Int     @id @default(autoincrement())
  title     String
datasource sqlite {
url = "file:data.db"
provider = "sqlite"
}
generator photonjs {
provider = "photonjs"
}
model User {

I'm using these prisma2 versions:

{
  "dependencies": {
    "@prisma/photon": "alpha"
  },
  "devDependencies": {
    "prisma2": "alpha",
    "ts-node-dev": "^1.0.0-pre.44",

Test

Challenge 1

Setup instructions:

git clone https://github.com/prisma/support-challenges
cd support-challenges/challenge-1
# Create local Postgres DB called "test1"
import { DMMF, DMMFClass, Engine } from './runtime';
/**
* Utility Types
*/
export declare type Enumerable<T> = T | Array<T>;
export declare type MergeTruthyValues<R extends object, S extends object> = {
[key in keyof S | keyof R]: key extends false ? never : key extends keyof S ? S[key] extends false ? never : S[key] : key extends keyof R ? R[key] : never;
};
export declare type CleanupNever<T> = {
[key in keyof T]: T[key] extends never ? never : key;
const UserType = new GraphQLObjectType({
name: 'User',
fields: {
id: { type: GraphQLID },
name: { type: GraphQLString },
},
})
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
type User {
id: ID!
name: String
}
type Query {
user(id: ID!): User
}
// express-graphql
const app = express()
app.use('/graphql', graphqlHTTP({ schema }))
app.listen(4000, () => {
console.log(`Server ready at http://localhost:4000`)
})