GraphQL: Difference between revisions
Jump to navigation
Jump to search
Line 210: | Line 210: | ||
* [https://a.kabachnik.info/offline-post-requests-via-service-worker-and-indexeddb.html Caching POST requests for offline use in a PWA] | * [https://a.kabachnik.info/offline-post-requests-via-service-worker-and-indexeddb.html Caching POST requests for offline use in a PWA] | ||
* [https://medium.com/codingthesmartway-com-blog/creating-a-graphql-server-with-node-js-and-express-f6dddc5320e1 A GraphQL Server With Node.js And Express] | * [https://medium.com/codingthesmartway-com-blog/creating-a-graphql-server-with-node-js-and-express-f6dddc5320e1 A GraphQL Server With Node.js And Express] | ||
* [https://dexie.org/docs/Tutorial/Getting-started Dexie.js - A JS library for IndexedDB] | |||
* [https://github.com/jonchenn/sw-graphql Service Worker GraphQL Example] | * [https://github.com/jonchenn/sw-graphql Service Worker GraphQL Example] | ||
* [https://developers.google.com/web/tools/workbox/ Workbox] | * [https://developers.google.com/web/tools/workbox/ Workbox] | ||
|} | |} |
Revision as of 23:02, 13 June 2020
Schema type Project {
name: String
tagline: String
contributors: [User]
}
|
Query {
project(name: "GraphQL") {
tagline
}
}
|
Results {
"project": {
"tagline": "A query language for APIs"
}
}
|
Scalar
About the types you can assign to fields or to the return values of operations. Graphql Java supports the following types:
String Boolean Int Float ID Long Short Byte Float BigDecimal BigInteger
Sencha Store
Ext/data/ ├─ operation/ │ ├─ Create [POST ] │ ├─ Destory [DELETE] │ ├─ Operation │ ├─ Read [GET ] │ └─ Update [PUT ] │ ├─ proxy/ │ ├─ Ajax │ ├─ Proxy │ └─ Rest |
│ ├─ reader/ │ ├─ Array │ ├─ JSON │ ├─ Reader │ └─ XML │ ├─ request/ │ ├─ Ajax │ ├─ Base │ └─ Form │ |
│ ├─ writer/ │ ├─ Array │ ├─ JSON │ └─ XML │ │ Ext/grid/filters/ ├─ filter └─ Filters |
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.JsonStore.html https://docs.sencha.com/extjs/6.2.0/classic/src/JsonStore.js.html
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.proxy.Rest.html https://docs.sencha.com/extjs/6.2.0/classic/src/Rest.js.html
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.proxy.Ajax.html https://docs.sencha.com/extjs/6.2.0/classic/src/Ajax.js-1.html
https://docs.sencha.com/extjs/6.2.0/classic/Ext.toolbar.Paging.html https://docs.sencha.com/extjs/6.2.0/classic/src/Paging.js.html
https://docs.sencha.com/extjs/6.2.0/classic/Ext.grid.filters.Filters.html https://docs.sencha.com/extjs/6.2.0/classic/src/Filters.js.html
Custom Scalar
@Component
public class DateScalarType extends GraphQLScalarType {
public DateScalarType() {
super("Date", "java.sql.Date", new Coercing<Date, String>() {
@Override
public String serialize(Object dataFetcherResult) throws CoercingSerializeException {
if(dataFetcherResult != null && dataFetcherResult instanceof Date) {
Date sqlDate = (Date)dataFetcherResult;
java.util.Date date = new Date(sqlDate.getTime());
String isoDate = DateUtil.format(date, DateUtil.ISO_DATE);
return isoDate;
}
return null;
}
@Override
public Date parseValue(Object input) throws CoercingParseValueException {
if(input != null && input instanceof String) {
String isoDate = (String)input;
java.util.Date date = DateUtil.parse(isoDate, DateUtil.ISO_DATE);
Date sqlDate = (date != null) ? new Date(date.getTime()) : null;
return sqlDate;
}
return null;
}
@Override
public Date parseLiteral(Object input) throws CoercingParseLiteralException {
if(input != null && input instanceof StringValue) {
String isoDate = ((StringValue)input).getValue();
java.util.Date date = DateUtil.parse(isoDate, DateUtil.ISO_DATE);
Date sqlDate = (date != null) ? new Date(date.getTime()) : null;
return sqlDate;
}
return null;
}
});
}
}
Handle Lazy Loads
import javax.servlet.Filter;
import org.springframework.context.annotation.Configuration
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;
@Configuration
public class SpringGraqphQLConfig {
/**
* Register the {@link OpenEntityManagerInViewFilter} so that the
* GraphQL-Servlet can handle lazy loads during execution.
*
* @return
*/
@Bean
public Filter OpenFilter() {
return new OpenEntityManagerInViewFilter();
}
}