Open frebliklo opened 5 years ago
It's on its way #2, hopefully tonight or tomorrow
Cool 😄Næste er vel at tænkte på nogle Mutations så 😉
Jeg har indført en swipe-mutation
type Swipe {
culture: CultureItem!
user: User!
choice: Boolean!
timestamp: Int!
}
mutation swipeCulture(user: ID!, culture: ID!, choice: Boolean!): Swipe!
Den kan nu testes live på '/graphiql' end-pointet. '/graphql' end-pointet er råt graphql der kan sendes med Content-Type: application/graphql. Der kræves "Authentication-Token" HTTP-header, at tilgå den. Der er et simpelt registrerings/loginflow.
POST /register (kræver lige nu gentagelse af pw) { "email": "", "first_name":"", "last_name":"", "password":"", "password_confirm":"" } response: { "response": { "user": { "authentication_token": "...", "id": "N" } } }
POST /login { "email": "", "password":"" } response: { "response": { "user": { "authentication_token": "...", "id": "N" } } }
@frebliklo Følgende skema er live nu.
Der er selvfølgeligt stadig nogle forskelle, mht. nullable felter, og hele strukturen med unions skal måske gentænkes... Men det kan i hvert fald afprøves ;-)
schema {
query: Query
mutation: Mutation
}
type AuthError {
message: String!
}
type AuthToken {
value: String!
}
union AuthorizedCultureItems = CultureList | AuthError
union AuthorizedMatches = MatchList | AuthError
union AuthorizedSwipe = Swipe | AuthError
union AuthorizedSwipes = SwipeList | AuthError
union AuthorizedToken = AuthToken | AuthError
union AuthorizedUser = User | AuthError
type CreateUserError {
message: String!
}
union CreateUserResult = User | CreateUserError
type CultureItem {
id: ID!
localId: String
title: String
image: JSONString
upvotes: Int
downvotes: Int
swipes: [Swipe]
}
type CultureList {
items: [CultureItem]!
}
scalar DateTime
scalar JSONString
type Match {
author: User!
matchUser: User!
seen: Boolean!
read: Boolean!
createdAt: Int!
}
type MatchList {
matches: [Match]
}
type Mutation {
swipeCulture(choice: Boolean!, culture: ID!, token: String!): AuthorizedSwipe
createUser(email: String!, firstName: String!, lastName: String!, password: String!): CreateUserResult
obtainToken(email: String!, password: String!): AuthorizedToken
}
type Query {
user(token: String!): AuthorizedUser
matches(token: String!): AuthorizedMatches
culture(count: Int, token: String!): AuthorizedCultureItems
swipes(token: String!): AuthorizedSwipes
}
type Swipe {
choice: Boolean
timestamp: DateTime
user: User
culture: CultureItem
}
type SwipeList {
swipes: [Swipe]
}
type User {
id: ID!
firstName: String
lastName: String
email: String
active: Boolean
facebookLinked: Boolean
googleLinked: Boolean
avatarUrl: String
roles: String
swipes: [Swipe]
}
A suggested schema for queries focused on the perspective of the frontend: