PHP
- 1 ответ
- 0 вопросов
1
Вклад в тег
'schemas' => [
'default' => [
'query' => [
\App\Http\GraphQL\Queries\UserQuery::class,
],
'mutation' => [
'createUser' => \App\Http\GraphQL\Mutations\CreateUserMutation::class,
],
'middleware' => [ ],
'method' => ['get', 'post'],
],
'auth' => [
'query' => [
\App\Http\GraphQL\Queries\GetMyProfileQuery::class,
],
'mutation' => [],
'middleware' => [
'api'
],
'method' => [ 'post'],
],
],
'schemas' => [
'default' => [
'query' => [
\App\Http\GraphQL\Queries\UserQuery::class,
\App\Http\GraphQL\Queries\GetMyProfileQuery::class,
],
'mutation' => [
'createUser' => \App\Http\GraphQL\Mutations\CreateUserMutation::class,
],
'middleware' => ['jwtAuth' ],
'method' => ['get', 'post'],
],
],
abstract class _BaseQuery extends Query
{
public function authorize(
$root,
array $args,
$ctx,
ResolveInfo $resolveInfo = null,
Closure $getSelectFields = null
): bool {
return Auth::check();
}
}
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import { RetryLink } from "@apollo/client/link/retry";
const directionalLink = new RetryLink().split(
(operation) => operation.getContext().version === 1,
new HttpLink({ uri: "http://localhost:4000/v1/graphql" }),
new HttpLink({ uri: "http://localhost:4000/v2/graphql" })
);
const client = new ApolloClient({
cache: new InMemoryCache(),
link: directionalLink,
});