Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
apollo-link-schema
Advanced tools
The schema link provides a graphql execution environment, which allows you to perform GraphQL operations on a provided schema. This type of behavior is commonly used for server-side rendering (SSR) to avoid network calls and mocking data. While the schema link could provide graphql results on the client, currently the graphql execution layer is too heavy weight for practical application. To unify your state management with client-side GraphQL operations, you should use apollo-link-state, because it integrates with the Apollo Client cache and is much more lightweight.
npm install apollo-link-schema --save
When performing SSR on the same server you can use this library to avoid making network calls.
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { SchemaLink } from 'apollo-link-schema';
import schema from './path/to/your/schema';
const graphqlClient = new ApolloClient({
ssr: true,
cache: new InMemoryCache(),
link: new SchemaLink({ schema })
});
For more detailed information about mocking, please look the graphql-tools documentation.
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { SchemaLink } from 'apollo-link-schema';
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
const typeDefs = `
Query {
...
}
`;
const mocks = {
Query: () => ...,
Mutation: () => ...
};
const schema = makeExecutableSchema({ typeDefs });
addMockFunctionsToSchema({
schema,
mocks
});
const apolloCache = new InMemoryCache(window.__APOLLO_STATE__);
const graphqlClient = new ApolloClient({
cache: apolloCache,
link: new SchemaLink({ schema })
});
The SchemaLink
constructor can be called with an object with the following properties:
schema
: an executable graphql schemarootValue
: the root value that is passed to the resolvers (i.e. the first parameter for the rootQuery)context
: an object passed to the resolvers, following the graphql specification or a function that accepts the operation and returns the resolver context. The resolver context may contain all the data-fetching connectors for an operation.FAQs
Use a GraphQL Schema to request data
The npm package apollo-link-schema receives a total of 17,513 weekly downloads. As such, apollo-link-schema popularity was classified as popular.
We found that apollo-link-schema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.