use of com.apollographql.apollo.api.Query in project apollo-android by apollographql.
the class ApolloCallTracker method registerCall.
/**
* <p>Adds provided {@link ApolloCall} that is currently in progress.</p>
*
* <p><b>Note</b>: This method needs to be called right before an apolloCall is executed.</p>
*/
void registerCall(@Nonnull ApolloCall call) {
checkNotNull(call, "call == null");
Operation operation = call.operation();
if (operation instanceof Query) {
registerQueryCall((ApolloQueryCall) call);
} else if (operation instanceof Mutation) {
registerMutationCall((ApolloMutationCall) call);
} else {
throw new IllegalArgumentException("Unknown call type");
}
}
use of com.apollographql.apollo.api.Query in project apollo-android by apollographql.
the class ResponseFetcherTest method setUp.
@Before
public void setUp() {
okHttpClient = new OkHttpClient.Builder().build();
emptyQuery = new Query() {
OperationName operationName = new OperationName() {
@Override
public String name() {
return "emptyQuery";
}
};
@Override
public String queryDocument() {
return "";
}
@Override
public Variables variables() {
return EMPTY_VARIABLES;
}
@Override
public ResponseFieldMapper<Data> responseFieldMapper() {
return new ResponseFieldMapper<Data>() {
@Override
public Data map(ResponseReader responseReader) {
return null;
}
};
}
@Nonnull
@Override
public OperationName name() {
return operationName;
}
@Nonnull
@Override
public String operationId() {
return "";
}
@Override
public Object wrapData(Data data) {
return data;
}
};
}
use of com.apollographql.apollo.api.Query in project apollo-android by apollographql.
the class RealApolloCall method prepareInterceptorChain.
private ApolloInterceptorChain prepareInterceptorChain(Operation operation) {
List<ApolloInterceptor> interceptors = new ArrayList<>();
HttpCachePolicy.Policy httpCachePolicy = operation instanceof Query ? this.httpCachePolicy : null;
ResponseFieldMapper responseFieldMapper = responseFieldMapperFactory.create(operation);
interceptors.addAll(applicationInterceptors);
interceptors.add(responseFetcher.provideInterceptor(logger));
interceptors.add(new ApolloCacheInterceptor(apolloStore, responseFieldMapper, dispatcher, logger));
interceptors.add(new ApolloParseInterceptor(httpCache, apolloStore.networkResponseNormalizer(), responseFieldMapper, scalarTypeAdapters, logger));
interceptors.add(new ApolloServerInterceptor(serverUrl, httpCallFactory, httpCachePolicy, false, scalarTypeAdapters, logger, sendOperationdIdentifiers));
return new RealApolloInterceptorChain(interceptors);
}
use of com.apollographql.apollo.api.Query in project apollo-android by apollographql.
the class ApolloCallTracker method unregisterCall.
/**
* <p>Removes provided {@link ApolloCall} that finished his execution, if it is found, else throws an
* {@link AssertionError}.</p>
*
* If the removal operation is successful and no active running calls are found, then the registered
* {@link ApolloCallTracker#idleResourceCallback} is invoked.
*
* <p><b>Note</b>: This method needs to be called right after an apolloCall is completed (whether successful or
* failed).</p>
*/
void unregisterCall(@Nonnull ApolloCall call) {
checkNotNull(call, "call == null");
Operation operation = call.operation();
if (operation instanceof Query) {
unregisterQueryCall((ApolloQueryCall) call);
} else if (operation instanceof Mutation) {
unregisterMutationCall((ApolloMutationCall) call);
} else {
throw new IllegalArgumentException("Unknown call type");
}
}
use of com.apollographql.apollo.api.Query in project apollo-android by apollographql.
the class ApolloExceptionTest method setUp.
@Before
public void setUp() {
apolloClient = ApolloClient.builder().serverUrl(server.url("/")).okHttpClient(new OkHttpClient.Builder().connectTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS).readTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS).build()).build();
emptyQuery = new Query() {
OperationName operationName = new OperationName() {
@Override
public String name() {
return "emptyQuery";
}
};
@Override
public String queryDocument() {
return "";
}
@Override
public Variables variables() {
return EMPTY_VARIABLES;
}
@Override
public ResponseFieldMapper<Data> responseFieldMapper() {
return new ResponseFieldMapper<Data>() {
@Override
public Data map(ResponseReader responseReader) {
return null;
}
};
}
@Nonnull
@Override
public OperationName name() {
return operationName;
}
@Nonnull
@Override
public String operationId() {
return "";
}
@Override
public Object wrapData(Data data) {
return data;
}
};
}
Aggregations