Comments (4)
I gave up using FraQL in the source code and am just using the normal gql
from graphql-tag
for fragments. I still wanted mocking so I'm using this helper function to pull the original query out, run it through FraQL's gql
and generate mock data for it. Let me know if you know any cleaner ways to do this 😃
import { IMocks } from 'graphql-tools';
import { DocumentNode } from 'graphql';
import gql from 'fraql';
import { createMockerFromIntrospection } from 'fraql/mock';
import introspectionQuery from '../schema.json';
import { globalMocks } from './globalMocks';
export const mockFragment = <TData>(
fragmentDocument: DocumentNode,
options?: {
mocks: IMocks;
},
): TData => {
if (!fragmentDocument.loc) {
throw 'Unable to get original gql query to create FraQL fragment.';
}
return createMockerFromIntrospection(introspectionQuery, {
mocks: globalMocks,
}).mockFragment(gql(fragmentDocument.loc.source.body), options);
};
from fraql.
FraQL has not evolve since a long time, it is probably the best choice to switch to graphql-tag
.
Your way of mocking looks great, nothing to change here.
from fraql.
Oh gotcha. Have you seen fragment mocking features added to any other libraries? Maybe there's a way to do it with graphql-tools
but it didn't seem immediately obvious. Thanks for the quick response and the update about the library 😄
from fraql.
I don't know if there is sorry!
from fraql.
Related Issues (7)
- Can I pass variables into different fragment of components HOT 1
- Babel macro support HOT 1
- Exclude fields from fragment ? HOT 1
- Benefits of fraql with vue? HOT 1
- Use lodash.assign instead of Object.assign polyfill for this to work on react-native HOT 2
- Having trouble getting readFragment to work. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fraql.