nextjs-apollo
Server side
new JsonWebToken(private or public keys, options)
const app = ; const jwt = apple: fs banana: fs toUser onSignIn onSignOut onRenew ; jwt; const apolloServer = typeDefs resolvers context: jwt;apolloServer; // if you enabled subscriptionconst server = http;apolloServer;server;
toUser()
{ return UserModel}
user
is plain object from client access token by decodeUserModel
any type will assign to context.user
onSignIn()
{ return issuer correlationId isUnfamiliar ...user ;}
correlationId
as http X-Correlation-ID is unique by all clientparams
is plain object from client.signIn(params) is username and password generallyissuer
is name of private key (option, when single key)isUnfamiliar
if is true when response correlationId and userData, but will not get new tokenuser
is plain object will encode to token
onSignOut()
{ return ... ;}
correlationId
as http X-Correlation-ID is unique by all clientparams
is plain object from client.signOut(params)
onRenew()
{ return correlationId ...user ;}
correlationId
as http X-Correlation-ID is unique by all clientuser
is plain object will encode to tokenissuer
is name of private key (option, when single key)params
is plain object from client.renew(params)
Client side
Component |> ;
uri
as URL.origin setup server addresshttp
is HttpLink optionspath
is${url.origin}${path}
default/graphql
...option
see apollo-link-http for the options
ws
path
is${url.origin}${path}
default/graphql
...option
see apollo-link-ws for the options
auth
path
is${url.origin}${path}
default/auth
params
is plain object will default to signIn, signOut and renew (option)headers
is plain object (option)
...option
see apollo-client
withConsumer()
withQuery()
Component static propTypes = results: PropTypesshape name: PropTypesshape name: PropTypesshape loading: PropTypesbool ...props const query = gql`query { node { id value } }`; |> ;
withConnection()
;
withCursorPagination()
;
withOffsetPagination()
;
withMutation()
Component static propTypes = results: PropTypesshape name: PropTypesshape name: PropTypesfunc ...props onClick = async { const name = thisprops; await nameinput options; } { return <button onClick=thisonClick /> }const mutation = gql` mutation($input: AddPostInput) { addPost(input: $input) { post: { id } } }`; |> ;
withSubscription()
Component static propTypes = results: PropTypesshape name: PropTypesshape name: PropTypesshape loading: PropTypesbool ...props const subscription = gql`subscription { onAddPost { id } }`; |> ;
withAuthorized()
Component |> ;